-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
sqltostr: fix str_to_date('2018-6-14', '%Y-%m-%d') bug #6919
Conversation
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
@mail2fish Thanks for your PR! |
/run-all-tests |
Review status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @mail2fish) types/time.go, line 2321 at r1 (raw file):
It'e better to put these two regex patterns together to a code block and make some comment for each one. types/time.go, line 2348 at r1 (raw file):
Since Comments from Reviewable |
types/time.go
Outdated
result := digitRegex.FindString(input) // 0..31 | ||
length := len(result) | ||
|
||
if length > 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it better to add some comments here why do you only take the suffix after index 2?
Review status: 0 of 2 files reviewed, 5 unresolved discussions (waiting on @mail2fish and @zhexuany) types/time.go, line 2357 at r2 (raw file):
I think we should keep the origin types/time.go, line 2447 at r2 (raw file):
can we remove this empty line? Comments from Reviewable |
types/time.go
Outdated
"%Y": yearNumericFourDigits, // Year, numeric, four digits | ||
"%b": abbreviatedMonth, // Abbreviated month name (Jan..Dec) | ||
"%c": monthNumeric, // Month, numeric (0..12) | ||
"%d": dayOfMonthNumeric, // Day of the month, numeric (00..31) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which the comment be needed to update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update "(00..31)" to "(0..31)"
"%k": hour24Numeric, // Hour (0..23) | ||
"%l": hour12Numeric, // Hour (1..12) | ||
"%M": fullNameMonth, // Month name (January..December) | ||
"%m": monthNumeric, // Month, numeric (00..12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the comment.
types/time.go
Outdated
v, rem := parseTwoNumeric(input) | ||
if len(rem) == len(input) || v > 12 { | ||
return rem, false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this empty line.
/run-all-tests |
/run-all-tests |
@mail2fish Please remove the empty line between the function declaration and the first code of that function, that empty line is meaningless and redundant. |
"%k": hour24Numeric, // Hour (0..23) | ||
"%l": hour12Numeric, // Hour (1..12) | ||
"%M": fullNameMonth, // Month name (January..December) | ||
"%m": monthNumeric, // Month, numeric (00..12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the comment.
types/time.go
Outdated
return input[2:], true | ||
} | ||
// digitRegex: it was used to scan a variable-length monthly day or month in the string. Ex: "01" or "1" or "30" | ||
var digitRegex = regexp.MustCompile("^[0-9]+") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^[0-9]{1,2}
is suitable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, It's better
types/time.go
Outdated
length = 2 | ||
} | ||
|
||
v, ok := parseDigits(input, length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For "20181120" the v would be 20?
return input, false | ||
} | ||
t.month = uint8(v) | ||
return remain, true | ||
t.day = uint8(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.month = uint8(v)
is a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so.
/run-all-tests |
types/time.go
Outdated
result := digitRegex.FindString(input) // 1..12 | ||
length := len(result) | ||
|
||
// Some time the input is a consecutive digital string. Ex: 20181120 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to say e.g.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just forgot to remove those lines
/run-all-tests |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM
"%T": time24Hour, // Time, 24-hour (hh:mm:ss) | ||
"%Y": yearNumericFourDigits, // Year, numeric, four digits | ||
"%b": abbreviatedMonth, // Abbreviated month name (Jan..Dec) | ||
"%c": monthNumeric, // Month, numeric (0..12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 0
should be 00
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-format
%c Month, numeric (0..12)
What have you changed? (mandatory)
fix #6835
What are the type of the changes (mandatory)?
bug fixed
How has this PR been tested (mandatory)?
make dev
Does this PR affect documentation (docs/docs-cn) update? (optional)
Refer to a related PR or issue link (optional)
#6835
Benchmark result if necessary (optional)
Add a few positive/negative examples (optional)