Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid MySQL syntax for date comparison #34

Open
PRGfx opened this issue Apr 20, 2021 · 0 comments
Open

Invalid MySQL syntax for date comparison #34

PRGfx opened this issue Apr 20, 2021 · 0 comments
Labels

Comments

@PRGfx
Copy link

PRGfx commented Apr 20, 2021

The date functions used in the MysqlQueryBuilder are copied from the SqliteQuerybuilder but don't work with mysql:

- sprintf("datetime(`%s`) %s strftime('%s', '%s')", $propertyName, $comparator, '%Y-%m-%d %H:%M:%S', $propertyValue->format('Y-m-d H:i:s'));
+ sprintf("`%s` %s str_to_date('%s', '%s')", $propertyName, $comparator, $propertyValue->format('Y-m-d H:i:s'), '%Y-%m-%d %H:%i:%S');

str_to_date takes the format as the second argument and minutes are %i.
Unfortunately I don't see a good solution for the first datetime call, as the format depends on the indexing configuration on the property. In my tests I got the impression that there is some implicit type conversion happening, but I'm not sure if that's really what's going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants