Skip to content

Invalid MySQL syntax for date comparison #34

Description

@PRGfx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions