-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11543 from stof/fix_native_query_parameter_type
Fix the support for custom parameter types in native queries
- Loading branch information
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Query; | ||
|
||
use DateTime; | ||
use Doctrine\DBAL\Types\Types; | ||
use Doctrine\ORM\Query\ResultSetMapping; | ||
use Doctrine\ORM\UnitOfWork; | ||
use Doctrine\Tests\Mocks\EntityManagerMock; | ||
use Doctrine\Tests\OrmTestCase; | ||
|
||
class NativeQueryTest extends OrmTestCase | ||
{ | ||
/** @var EntityManagerMock */ | ||
protected $entityManager; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->entityManager = $this->getTestEntityManager(); | ||
} | ||
|
||
public function testValuesAreNotBeingResolvedForSpecifiedParameterTypes(): void | ||
{ | ||
$unitOfWork = $this->createMock(UnitOfWork::class); | ||
|
||
$this->entityManager->setUnitOfWork($unitOfWork); | ||
|
||
$unitOfWork | ||
->expects(self::never()) | ||
->method('getSingleIdentifierValue'); | ||
|
||
$rsm = new ResultSetMapping(); | ||
|
||
$query = $this->entityManager->createNativeQuery('SELECT d.* FROM date_time_model d WHERE d.datetime = :value', $rsm); | ||
|
||
$query->setParameter('value', new DateTime(), Types::DATETIME_MUTABLE); | ||
|
||
self::assertEmpty($query->getResult()); | ||
} | ||
} |