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
Feature TIMEDIFF and TIMESTAMPDIFF function expressions #17614
base: 5.next
Are you sure you want to change the base?
Conversation
5.x: fix undefined property warning
Fix up parsing of datetime string with microseconds.
Add test for int backed in Form control().
…F" along with test cases
…unctions are only available in MySQL.
Should probably target 5.next |
…ySQL, since the functions are only available in MySQL
I am concerned about adding too many built-in functions that are supported by a single db engine only. |
I share the same concern. |
I also share the concern about adding functions that are only supported on a single SQL dialect. Are any of these functions we can simulate or approximate in other platforms? It looks like sqlite has timediff. and postgres allows operations like |
I like the idea of approximating in the three other SQL dialects, and I've done some testing. The formats are vastly different, and a CakePHP dev may expect the result to be returned as an object which is easy to interact with. A DateTimeInterval object of some sort. Let me know what you think and how I may proceed with this PR. Test results:
MySQL / MariaDB: Postgres: SQLServer Express: sqlite3:
MySQL / MariaDB: Postgres: sqlite3: SQLServer Express: |
The results for |
feat: added sql function expressions for "TIMEDIFF" and "TIMESTAMPDIFF"
Currently the
dateDiff
method already exists in\Cake\Database\FunctionsBuilder
, but not for either "TIMEDIFF" or "TIMESTAMPDIFF" SQL functions.Note: The new functions only work in MySQL, which I've added a comment in the method docblocks.