Sqlite support both integer and field reference intervals in date functions#2482
Sqlite support both integer and field reference intervals in date functions#2482vhraban wants to merge 3 commits intodoctrine:4.0.xfrom
Conversation
| * @param string $date | ||
| * @param integer $seconds | ||
| * @param string $date | ||
| * @param integer|string $seconds |
There was a problem hiding this comment.
All of these should be reverted: we shouldn't accept strings, and should be very strict about this due to SQL injection concerns
There was a problem hiding this comment.
I see what you mean by this, but string is not valid here. Must be something like an expression object, or a field reference. /cc @deeky666
There was a problem hiding this comment.
As far as I know, there is no Expr to represent datetime arithmetics. Field reference can not be represented as a data type either. Leaving this just an integer does not reflect how this method can be used. I can not see any good way of doing this PHPDoc at all apart of introducing datetime Expr that goes far beyond this issue. What would you suggest?
There was a problem hiding this comment.
No, what I'm saying is creating an Expr object or such. Passing around strings here is just going to be causing more and more problems in the future :(
There was a problem hiding this comment.
@deeky666 do you have suggestions about how to design this API, eventually?
|
Please do not close this ticket due to inactivity, I will have a proper look into it the next week |
I stumbled upon a problem that my query worked in MySQL but not SQLite. As it turns out, when using SQLite it is not possible to perform date arithmetic on field references, only on actual integers.
This works
generating (roughly)
This does not
Because this will get generated
My fix adds support to reference other fields in the query, so that the first code example works the same way, but the second one uses SQLite concat symbol and generates the following:
I've got only two concerns regarding this: