Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Invalid
-
Affects Version/s: Git Master, 2.3.1
-
Fix Version/s: None
-
Component/s: ORM
-
Security Level: All
-
Labels:None
Description
Following discussion on Google Groups:
https://groups.google.com/d/msg/doctrine-dev/-/gG-VGiAGQiMJ
When using a mapping type which declares convertToDatabaseValueSQL(), this method is not invoked when passing a value as parameter to a DQL query.
For example, if I declare a mapping type MyType:
class MyType extends \Doctrine\DBAL\Types\Type { public function canRequireSQLConversion() { return true; } public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) { return sprintf('FUNCTION(%s)', $sqlExpr); } // ... }
And pass a parameter with this type to a DQL query:
$query = $em->createQuery('SELECT e FROM Entity e WHERE e.field = :field');
$query->setParameter('field', $value, 'MyType');
I would expect the following SQL to be generated:
SELECT ... WHERE ... = FUNCTION(?)
But the current SQL generated is the following:
SELECT ... WHERE ... = ?
Issue Links
- duplicates
-
DDC-2240
Inconsistent querying for parameter type (from ClassMetadata) between using Find/FindBy and DoctrineQL
-
Fix proposal: https://github.com/doctrine/doctrine2/pull/574