sidorares / sidorares/node-mysql2
Strange behavior of timezone
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
I found that the timezone behavior for DATETIME is a little strange, could you help to confirm it?
My timezone is +8, this is my test environment.
- MySQL: 8.0.30
- Node: 20.6.1
- Mysql2: 3.6.2
Command to get connectio pool:
pool = require('mysql2/promise').createPool({
host: xxx,
user: xxx,
password: xxx,
database: xxx,
timezone: "******"
});
This is my test data.
mysql> select rec_dt from TB1;
+---------------------+
| rec_dt |
+---------------------+
| 2023-10-13 09:15:57 |
+---------------------+
This is my test result.
- timezone is not set, it returns 2023-10-13T01:15:57.000Z
- timezone is "local", it returns 2023-10-13T01:15:57.000Z => it should be 09:15:57, and not add 'Z'
- timezone is "Z", it returns 2023-10-13T09:15:57.000Z => it should be 01:15:57
- timezone is "xxxxx", it returns 2023-10-13T09:15:57.000Z
of course, I got an error message when I set it to xxx, Ignoring invalid timezone passed to Connection: xxxxx. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the createPool timezone option and the DATETIME result parsing path, using the supplied MySQL, Node, and mysql2 versions to reproduce each timezone setting. Compare the returned values with the reported database value and determine the intended behavior for invalid timezone strings; done means the behavior is confirmed and the issue has a specific expected outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, nodejs
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100