Commit 33f22a9
fix: replace fragile datetime string slicing with robust parser (#20)
* fix: replace fragile datetime string slicing with robust parser (#6)
Replace hardcoded `res[:23]` truncation with `_parse_datetime()` helper
that preserves microsecond precision and handles variable-length
fractional seconds, timezone suffixes, and trailing whitespace.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address review feedback for datetime parsing
- Normalize Z suffix to +00:00 for Python 3.10 compatibility
- Add error logging at call site before ValueError propagates
- Fix incorrect skipif guard on timezone test (+HH:MM works on 3.7+)
- Add tests: Z suffix, 7-digit boundary, leading whitespace,
nanoseconds with timezone, empty string
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: remove incorrect skipif and add missing edge case tests
- Remove skipif on test_nanosecond_precision_with_timezone — after
truncation the string is valid on Python 3.10
- Add test_nanosecond_precision_with_z_suffix (combined Z + truncation)
- Add test_trailing_dot_raises (malformed fractional seconds)
- Remove unused sys import
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address remaining review suggestions
- Expand docstring to document all normalizations (whitespace, Z suffix,
truncation)
- Add defensive guards for empty/missing datetime results, matching the
existing int path
- Enrich error log with database name and SQL context
- Add tests: all-nines truncation boundary, negative timezone offset
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 13963a4 commit 33f22a9
2 files changed
Lines changed: 110 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
84 | 105 | | |
85 | 106 | | |
86 | 107 | | |
| |||
985 | 1006 | | |
986 | 1007 | | |
987 | 1008 | | |
988 | | - | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
989 | 1015 | | |
990 | | - | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
991 | 1026 | | |
992 | 1027 | | |
993 | 1028 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
0 commit comments