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
-
Activity
Benjamin Morel
made changes -
| Field | Original Value | New Value |
|---|---|---|
| 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: {code} class MyType extends \Doctrine\DBAL\Types\Type { public function canRequireSQLConversion() { return true; } public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) { return sprintf('FUNCTION(%s)', $sqlExpr); } // ... } {code} And pass a parameter with this type to a DQL query: {code} $query = $em->createQuery('SELECT e FROM Entity e WHERE e.field = :field'); $query->setParameter('field', $value, 'MyType'); {code} I would expect the following SQL to be generated: {code} SELECT ... WHERE ... = FUNCTION(?) {code} But the current SQL generated is the following: {code} SELECT ... WHERE ... = ? {code} |
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}}: {code} class MyType extends \Doctrine\DBAL\Types\Type { public function canRequireSQLConversion() { return true; } public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) { return sprintf('FUNCTION(%s)', $sqlExpr); } // ... } {code} And pass a parameter with this type to a DQL query: {code} $query = $em->createQuery('SELECT e FROM Entity e WHERE e.field = :field'); $query->setParameter('field', $value, 'MyType'); {code} I would expect the following SQL to be generated: {code} SELECT ... WHERE ... = FUNCTION(?) {code} But the current SQL generated is the following: {code} SELECT ... WHERE ... = ? {code} |
Benjamin Morel
made changes -
| Attachment | DDC2224Test.php [ 11367 ] |
Benjamin Morel
made changes -
| 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}}: {code} class MyType extends \Doctrine\DBAL\Types\Type { public function canRequireSQLConversion() { return true; } public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) { return sprintf('FUNCTION(%s)', $sqlExpr); } // ... } {code} And pass a parameter with this type to a DQL query: {code} $query = $em->createQuery('SELECT e FROM Entity e WHERE e.field = :field'); $query->setParameter('field', $value, 'MyType'); {code} I would expect the following SQL to be generated: {code} SELECT ... WHERE ... = FUNCTION(?) {code} But the current SQL generated is the following: {code} SELECT ... WHERE ... = ? {code} |
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}}: {code} class MyType extends \Doctrine\DBAL\Types\Type { public function canRequireSQLConversion() { return true; } public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) { return sprintf('FUNCTION(%s)', $sqlExpr); } // ... } {code} And pass a parameter with this type to a DQL query: {code} $query = $em->createQuery('SELECT e FROM Entity e WHERE e.field = :field'); $query->setParameter('field', $value, 'MyType'); {code} I would expect the following SQL to be generated: {code} SELECT ... WHERE ... = FUNCTION(?) {code} But the current SQL generated is the following: {code} SELECT ... WHERE ... = ? {code} |
Benjamin Morel
made changes -
| Comment | [ A test case for this bug. ] |
Benjamin Morel
made changes -
| Attachment | DDC2224Test.php [ 11367 ] |
Benjamin Morel
made changes -
| Attachment | DDC2224Test.php [ 11369 ] |
Benjamin Eberlei
made changes -
Benjamin Eberlei
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Invalid [ 6 ] |