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

Return timestamp as UTC instead of converting to local timezone #442

Closed
soulee-dev opened this issue Aug 24, 2023 · 0 comments · Fixed by #443
Closed

Return timestamp as UTC instead of converting to local timezone #442

soulee-dev opened this issue Aug 24, 2023 · 0 comments · Fixed by #443

Comments

@soulee-dev
Copy link
Contributor

Issue

I recently encountered an issue while testing python-mysql replication, specifically with the test_timestamp. The tests failed due to a discrepancy in handling timestamps.

Details

When a timestamp is inserted into MySQL, the MySQL server converts values from the local timezone to UTC for storage. The replication protocol sends the UTC timestamp, which is in line with the expected behavior.

However, python-mysql-replication appears to convert the timestamp into the local timezone by calling fromtimestamp, leading to unexpected behavior in the tests.

I ran containers with docker-compose, and ran tests on a local Mac system with a time difference of UTC+9 (Korean Standard Timezone), and this seems to be the source of the failure.

Expected Behavior

Considering that this project's philosophy is to parse the replication protocol and pass them to users, I believe it would be more appropriate to return timestamps as UTC, not as the user's local timezone. This change would align with the way MySQL itself handles timestamps, ensuring consistency and predictable behavior.

Potential Impact

I suspect that other projects that interact with this part of the code may be affected as well. If it's deemed necessary, I'm willing to create related issues in those projects.

Solution

I kindly request that you consider modifying the timestamp conversion to return the timestamp as UTC rather than converting it to the local timezone. If desired, I'm willing to assist with a pull request or further discussion to address this issue.

Thank you for your attention to this matter.

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