Bug #113121 | The value '24:00:00' is an invalid TIME value. | ||
---|---|---|---|
Submitted: | 17 Nov 2023 13:34 | Modified: | 18 Nov 2023 16:49 |
Reporter: | Jan Burkhardt | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / J | Severity: | S3 (Non-critical) |
Version: | 8.2.0 | OS: | Linux |
Assigned to: | CPU Architecture: | x86 |
[17 Nov 2023 13:34]
Jan Burkhardt
[17 Nov 2023 13:37]
Jan Burkhardt
The Test to reproduce the bug
Attachment: TimeBug.java (text/x-java), 1.52 KiB.
[17 Nov 2023 14:46]
Jan Burkhardt
you can check it out here https://github.com/bjrke/mysqlbug/blob/main/src/main/java/de/bjrke/mysqlbug/TimeBug.java
[18 Nov 2023 0:54]
Filipe Silva
Hi Jan, Thank you for your interest in MySQL Connector/J and for filing this report. First of all please note that "24:00:00" is not a valid java.sql.Time value, so your request for making Connector/J support it the way you want will simply not be possible. You have at least two options to handle this situation, though. Taking it from the server side, you can create your TIME columns with fractional seconds support, for example, as "TIME(3)" [https://dev.mysql.com/doc/refman/8.2/en/fractional-seconds.html]. Just by doing so your test should pass. From the client side, if you don't want to sanitize the data yourself in order to keep time values within the valid range before submitting it, then you can set the connection option "sendFractionalSecondsForTime=false" and Connector/J does the fractional seconds truncation for you. Or else you will just have to retrieve the values as strings, via statement.getString(time), and then process them however you like. I hope this helps.
[18 Nov 2023 16:49]
Jan Burkhardt
I have a different opinion about it, since using it straight forward, like I demonstrated, shows the issue. A default behavior should not have such a restriction. Especially since I just request to allow 24:00:00, but not 24:00:01. I found the workaround of using Time.valueOf(rs.getString()) myself. But I spend a whole day in investigating, fixing and deploying this issue after it happened in production, because of its low chance (1:172800). Migrating to a different column type is not an option since we don't need this precision. Additionally in english speaking countries 12AM is midnight, not 0AM.