mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2224: convertToDatabaseValueSQL() is not honored for DQL query parameters #2798
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jan 5, 2013).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user benjamin:
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:And pass a parameter with this type to a DQL query:
I would expect the following SQL to be generated:
But the current SQL generated is the following:
@doctrinebot commented on GitHub (Jan 5, 2013):
@doctrinebot commented on GitHub (Feb 8, 2013):
Comment created by mnapoli:
Fix proposal: https://github.com/doctrine/doctrine2/pull/574
@doctrinebot commented on GitHub (Feb 8, 2013):
Comment created by mnapoli:
It turns out convertToDatabaseValue() is not called as well.
For example:
The SQL generated should not change, but the parameter should go through "convertToDatabaseValue", which is not the case.
@doctrinebot commented on GitHub (Feb 8, 2013):
Comment created by benjamin:
Have you passed the type as the third parameter to setParameter() ?
Because this works fine for me!
@doctrinebot commented on GitHub (Feb 8, 2013):
Comment created by mnapoli:
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?
@doctrinebot commented on GitHub (Feb 8, 2013):
Comment created by benjamin:
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:
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:
Here, there's no ambiguity, and if
entity.fieldhas a custom mapping type, then I can't see a reason why it shouldn't be applied to the parameter by default.@doctrinebot commented on GitHub (Feb 8, 2013):
Comment created by mnapoli:
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
@doctrinebot commented on GitHub (Apr 4, 2013):
Issue was closed with resolution "Invalid"
@BenMorel commented on GitHub (May 26, 2016):
@beberlei @mnapoli I think this bug has been closed by mistake. Can you reopen it, or should I create a new one?
Three years later, it would be nice to fix this bug that regularly bites me!
@Ocramius commented on GitHub (May 26, 2016):
I can re-open, but we'll need a test case
@BenMorel commented on GitHub (May 26, 2016):
@Ocramius While trying to create a test case, I realized that this bug has actually been fixed!
It is another bug I stumbled upon, in the Paginator. I will open another bug when I can produce a minimal test case. You can close this bug again, thank you!
@mnapoli commented on GitHub (May 26, 2016):
Well that was fast ;)
@Ocramius commented on GitHub (May 26, 2016):
Aaaaand re-closing :-)
@BenMorel commented on GitHub (May 26, 2016):
No time to lose ;-) Sorry for the confusion anyway. Reported as #5839.