Jira issue originally created by user mnapoli:
When using a mapping Type that declares convertToDatabaseValue, the method is not always called in queries.
SELECT ... WHERE entity.field = ?1
(with entity.field being of custom type 'themappingtype')
Type::convertToDatabaseValue() is correctly called when using:
$query->setParameter('1', 'foo', 'the*mapping*type');
But it is not called when using:
which gives a query that returns invalid results.
Like other mapping types in this situation, there is no reason the type is not inferred automatically from the field.
I have written a failing test case in Doctrine\Tests\ORM\Functional\TypeValueSqlTest:
public function testQueryParameterWithoutType()
$entity = new CustomTypeUpperCase();
$entity->lowerCaseString = 'foo';
$id = $entity->id;
$query = $this->_em->createQuery('SELECT c.id from Doctrine\Tests\Models\CustomType\CustomTypeUpperCase c where c.lowerCaseString = ?1');
$result = $query->getResult();
Comment created by mnapoli:
See also http://www.doctrine-project.org/jira/browse/[DDC-2224](http://www.doctrine-project.org/jira/browse/DDC-2224)
The test is in this branch: https://github.com/myc-sense/doctrine2/tree/[DDC-2290](http://www.doctrine-project.org/jira/browse/DDC-2290)
The organization name has changed so the previous URL is a 404.
Here is the branch containing the failing testcase: https://github.com/myclabs/doctrine2/tree/[DDC-2290](http://www.doctrine-project.org/jira/browse/DDC-2290)
Comment created by benjamin:
Any news on this one? Also, I just noticed that it does not cover the original problem I've reported in DDC-2224: I was specifically talking about convertToDatabaseValueSQL() and not convertToDatabaseValue().
My problem is that even when passing the third parameter $type, it does not use the conversion function from convertToDatabaseValueSQL().
Should we reopen DDC-2224?
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1339] was unlabeled:
A related Github Pull-Request [GH-1339] was assigned:
A related Github Pull-Request [GH-1339] was merged:
Lack of this feature seems to be the root cause of #4632