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

Add a mysql_session_timezone define to disable MySQL date functions #154

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

cedx
Copy link
Member

@cedx cedx commented Oct 26, 2023

The problem: the Node.js driver for MySQL uses the DATE_ADD function to handle Date values. But MySQL date functions don't correctly handle daylight saving time.

Currently, on my servers using the Europe/Paris time zone, the queries generated give incorrect results:

SELECT UNIX_TIMESTAMP('2023-10-25 00:00:00');
-- 1698184800, same as: Date.fromString('2023-10-25 00:00:00').getTime() / 1000

SELECT DATE_ADD(FROM_UNIXTIME(0), INTERVAL 1698184800 SECOND);
-- 2023-10-24 23:00:00 !!!

This issue does not occur with the PHP/PDO driver which converts dates to yyyy-mm-dd hh:hh:ss strings.
https://github.com/haxetink/tink_sql/blob/master/src/tink/sql/drivers/php/PDO.hx#L86

This PR adds a mysql_session_timezone define to disable the use of MySQL date functions in the Node.js driver, bringing it into line with the PDO driver.

@cedx cedx merged commit c940d97 into master Oct 26, 2023
16 checks passed
@cedx cedx deleted the feature/mysql_dates_as_string branch October 26, 2023 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant