Commit 71dcca2
committed
Correct timedelta value for negative MySQL TIME datatype
1. minimum value for MySQL TIME datatype:
'-838:59:59.000000' = ADDTIME('-838:00:00', ADDTIME('-00:59:00', '-00:00:59'))
2. appropriate timedelta representation of the same value in Python:
datetime.timedelta(hours=-838, minutes=-59, seconds=-59)
= -1 * datetime.timedelta(hours=838, minutes=59, seconds=59)
'sign' must be multiplied to the entire timedelta value,
not just to the 'hours' value as in the existing code.
refer to convert_timedelta() in pymysql:
https://github.com/PyMySQL/PyMySQL/blob/master/pymysql/converters.py#L189
Datatype tests were modified to test the correct minimum value for TIME datatype.1 parent 3de6ff4 commit 71dcca2
2 files changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| |||
0 commit comments