We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
MySQL STR_TO_DATE can parse "%Y%m%d" format. But go-mysql-server cannot parse it.
MySQL:
mysql> select STR_TO_DATE('20240801', '%Y%m%d'); +-----------------------------------+ | STR_TO_DATE('20240801', '%Y%m%d') | +-----------------------------------+ | 2024-08-01 | +-----------------------------------+
When you added the following test case, it fails.
diff --git a/sql/expression/function/str_to_date_test.go b/sql/expression/function/str_to_date_test.go index 19e96dac5..32fd0277e 100644 --- a/sql/expression/function/str_to_date_test.go +++ b/sql/expression/function/str_to_date_test.go @@ -21,6 +21,7 @@ func TestStrToDate(t *testing.T) { expected string }{ {"standard", "Dec 26, 2000 2:13:15", "%b %e, %Y %T", "2000-12-26 02:13:15"}, + {"ymd", "20240101", "%Y%m%d", "2024-01-01 00:00:00"}, } for _, tt := range testCases {
Test Result:
--- FAIL: TestStrToDate (0.00s) --- FAIL: TestStrToDate/ymd (0.00s) str_to_date_test.go:37: Error Trace: /home/ktat/git/github/go-mysql-server/sql/expression/function/str_to_date_test.go:37 Error: Not equal: expected: string("2024-01-01 00:00:00") actual : <nil>(<nil>) Test: TestStrToDate/ymd FAIL FAIL command-line-arguments 0.010s FAIL
I checked the part of parsing year, parseYear4DigitNumeric for `%Y' is usef in the following code.
year, rest, err := takeNumber(chars)
It takes "20240101" as year and rest is empty.
Shoud use takeNumberAtMostNChars instead of takeNumber ?
takeNumberAtMostNChars
The text was updated successfully, but these errors were encountered:
additional information. MySQL STR_TO_DATE behavior
mysql> select STR_TO_DATE('2024121', '%Y%m%d'), STR_TO_DATE('2024810', '%Y%m%d'), STR_TO_DATE('202411', '%Y%m%d'); +----------------------------------+----------------------------------+---------------------------------+ | STR_TO_DATE('2024121', '%Y%m%d') | STR_TO_DATE('2024810', '%Y%m%d') | STR_TO_DATE('202411', '%Y%m%d') | +----------------------------------+----------------------------------+---------------------------------+ | 2024-12-01 | NULL | NULL | +----------------------------------+----------------------------------+---------------------------------+
Sorry, something went wrong.
Fix str_to_date function
bf4bf91
- Bug fix: cannot parse "%Y%m%d" format dolthub#2666
Issue is resolved by: #2666
Thanks!
No branches or pull requests
MySQL STR_TO_DATE can parse "%Y%m%d" format. But go-mysql-server cannot parse it.
MySQL:
When you added the following test case, it fails.
Test Result:
I checked the part of parsing year, parseYear4DigitNumeric for `%Y' is usef in the following code.
It takes "20240101" as year and rest is empty.
Shoud use
takeNumberAtMostNChars
instead of takeNumber ?The text was updated successfully, but these errors were encountered: