Matthieu Napoli
added a comment - 08/Feb/13 10:16 AM It turns out convertToDatabaseValue() is not called as well.
For example:
class MyType extends \Doctrine\DBAL\Types\Type
{
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return serialize($value);
}
// ...
}
The SQL generated should not change, but the parameter should go through "convertToDatabaseValue", which is not the case.

But shouldn't the Type mapping be taken into account anyway? I makes sense to me at least (a column has a type, when I specify a parameter for this column, it is for this type), but maybe that was just designed that way?

Matthieu Napoli
added a comment - 08/Feb/13 10:29 AM You are right!
But shouldn't the Type mapping be taken into account anyway? I makes sense to me at least (a column has a type, when I specify a parameter for this column, it is for this type), but maybe that was just designed that way?

That would make sense, but I think that because of the flexibility of DQL, it's not always obvious what type you want to use.
Say you have some complex expression like:

WHERE entity.field = SomeDQLFunction(:value, entity.otherField)

Then we can't be sure what mapping type to use here (unless we can infer it from SomeDQLFunction, but this is yet another story).
Though I do agree that would be great to have the type inferred automatically when you do a simple:

WHERE entity.field = :value

Here, there's no ambiguity, and if entity.field has a custom mapping type, then I can't see a reason why it shouldn't be applied to the parameter by default.

Benjamin Morel
added a comment - 08/Feb/13 10:49 AM - edited That would make sense, but I think that because of the flexibility of DQL, it's not always obvious what type you want to use.
Say you have some complex expression like:
WHERE entity.field = SomeDQLFunction(:value, entity.otherField)
Then we can't be sure what mapping type to use here (unless we can infer it from SomeDQLFunction , but this is yet another story).
Though I do agree that would be great to have the type inferred automatically when you do a simple:
WHERE entity.field = :value
Here, there's no ambiguity, and if entity.field has a custom mapping type, then I can't see a reason why it shouldn't be applied to the parameter by default.

Matthieu Napoli
added a comment - 08/Feb/13 11:27 AM - edited I made a failing test case, I'll see if I can work on that.
I will open a separate ticket for this.
Edit: http://www.doctrine-project.org/jira/browse/DDC-2290