DDC-3691: Filtering by 'date' column does not return enough values on SQLite #4534

Open
opened 2026-01-22 14:44:15 +01:00 by admin · 7 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 14, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user XitasoChris:

When using a column of type 'date' in a where clause, filtering fails and does not return entries which clearly should match.

I have implemented a small proof of concept on the Doctrine sandbox. You can find it by checking out my branch at https://github.com/XitasoChris/doctrine2/tree/datefilterbug and then run the tools/sandbox/index.php . Alternatively, I have zipped the sandbox folder and attached it to this bug report.

I don't know whether this affects other database systems as well. I only tested it on SQLite.

Originally created by @doctrinebot on GitHub (Apr 14, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user XitasoChris: When using a column of type 'date' in a where clause, filtering fails and does not return entries which clearly should match. I have implemented a small proof of concept on the Doctrine sandbox. You can find it by checking out my branch at https://github.com/XitasoChris/doctrine2/tree/date*filter*bug and then run the tools/sandbox/index.php . Alternatively, I have zipped the sandbox folder and attached it to this bug report. I don't know whether this affects other database systems as well. I only tested it on SQLite.
admin added the Bug label 2026-01-22 14:44:15 +01:00
Author
Owner

@doctrinebot commented on GitHub (Apr 14, 2015):

Comment created by @ocramius:

Linking the diff: https://github.com/doctrine/doctrine2/compare/master...XitasoChris:datefilterbug

Should be a test case, [~XitasoChris] - can you convert it?

@doctrinebot commented on GitHub (Apr 14, 2015): Comment created by @ocramius: Linking the diff: https://github.com/doctrine/doctrine2/compare/master...XitasoChris:date*filter*bug Should be a test case, [~XitasoChris] - can you convert it?
Author
Owner

@doctrinebot commented on GitHub (Apr 14, 2015):

Comment created by XitasoChris:

@Marco: I will try, though I have never done that on the doctrine project before.

@doctrinebot commented on GitHub (Apr 14, 2015): Comment created by XitasoChris: @Marco: I will try, though I have never done that on the doctrine project before.
Author
Owner

@doctrinebot commented on GitHub (Apr 14, 2015):

Comment created by XitasoChris:

Test case created: https://github.com/doctrine/doctrine2/pull/1383

@doctrinebot commented on GitHub (Apr 14, 2015): Comment created by XitasoChris: Test case created: https://github.com/doctrine/doctrine2/pull/1383
Author
Owner

@doctrinebot commented on GitHub (Apr 17, 2015):

Comment created by XitasoChris:

After some more debugging: The problem is that the type of the parameter is inferred as "datetime", leading Doctrine to format the value as "2015-03-01 00:00:00". However, SQLite needs the value formatted as "2015-03-01" to find a match.

A workaround is to tell Doctrine to format the parameter as a date [$queryBuilder->setParameter("date", $date, "date")] and then the test case works fine.

My question now is: is this behavior expected? If so, then the bug report is probably invalid.

@doctrinebot commented on GitHub (Apr 17, 2015): Comment created by XitasoChris: After some more debugging: The problem is that the type of the parameter is inferred as "datetime", leading Doctrine to format the value as "2015-03-01 00:00:00". However, SQLite needs the value formatted as "2015-03-01" to find a match. A workaround is to tell Doctrine to format the parameter as a date [$queryBuilder->setParameter("date", $date, "date")] and then the test case works fine. My question now is: is this behavior expected? If so, then the bug report is probably invalid.
Author
Owner

@doctrinebot commented on GitHub (Jul 15, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1383] was labeled:
https://github.com/doctrine/doctrine2/pull/1383

@doctrinebot commented on GitHub (Jul 15, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1383] was labeled: https://github.com/doctrine/doctrine2/pull/1383
Author
Owner

@aaronm-cloudtek commented on GitHub (Jan 10, 2018):

Perhaps this could be added to http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/known-vendor-issues.html?

@aaronm-cloudtek commented on GitHub (Jan 10, 2018): Perhaps this could be added to http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/known-vendor-issues.html?
Author
Owner

@lcobucci commented on GitHub (Feb 22, 2018):

@aaronm-cloudtek could you send a PR for DBAL to improve our docs?

@lcobucci commented on GitHub (Feb 22, 2018): @aaronm-cloudtek could you send a PR for DBAL to improve our docs?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4534