Repository navigation
Conversation
…s SQLite does With `extended_types = TRUE`, text ending in a negative UTC offset such as `-05:00` was misread without a warning, because boost took the offset for a fraction of a second. The parser now splits off a trailing offset in the forms SQLite's date functions accept, `Z` or `[+-]HH:MM` with hours up to 14, and applies it, so the result matches `datetime()` and `time()`. A time of day with an offset wraps around midnight, as in `time()`. Other text after the time that starts with a sign or `Z`, such as `-0500`, gives `NA` with a warning, as SQLite gives `NULL`. Closes #877. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7mthffYErGmWTGDfQ
`split_utc_offset()` applied the offset to any duration boost reads, so `'25:00:00-02:00'` became 03:00:00 and `'-01:00:00+00:00'` became 23:00:00, where SQLite's `time()` gives `NULL`. A TIME with an offset now has to be `HH:MM[:SS[.SSS]]` with hours up to 24, minutes and seconds up to 59, and hour 24 only as 24:00:00, otherwise it gives `NA` with a warning. `'24:00:00+00:00'` reads as 00:00:00, as in `time()`; without an offset, `'24:00:00'` stays a duration of 24 hours, as before. Document in the Extended Types section that a trailing offset is applied and that a TIME with an offset becomes a time of day in UTC. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7mthffYErGmWTGDfQ
|
Review of this pull request at ec9d698, by a Claude Code reviewer with clean context that read issue #877, the description of #885, its diff against What was run
What holds
HighNone. MediumNone. Low
Generated by Claude Code |
Superseded: Accepted limitationsSuperseded by #885 (comment). One review round, found nothing above Low. 9343c20 fixes both Low findings the pull request introduced. A TIME with an offset must now be a time of day that SQLite's
Generated by Claude Code |
|
Is there a Boost update that we could vendor that would fix the problem too? |
|
No, I don't think so. The Boost headers in I also checked this by compiling the same calls against the vendored 1.81 headers and against BH 1.90.0-1 from CRAN. The output was identical for every input. Generated by Claude Code |
Accepted limitationsOne review round, found nothing above Low. 9343c20 fixes both Low findings the pull request introduced. A TIME with an offset must now be a time of day that SQLite's
Generated by Claude Code |
…ve-utc-offset Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
With
extended_types = TRUE,dbFetch()misread text in TIMESTAMP, DATETIME and TIME columns that ends in a negative UTC offset, and gave no warning. Boost's tokenizer splits on-, so it read the offset as a fraction of a second:'2024-01-02 12:00:00-05:00'came back as 12:00:00.05 UTC. Python'ssqlite3module writes aware timestamps in this form, so a timestamp written anywhere west of UTC came back hours off. SQLite's owndatetime()reads the same text as 17:00:00.The parser now splits a trailing offset off before boost reads the text, then applies the offset. It accepts the forms SQLite's date and time functions accept:
Z, or[+-]HH:MMwith hours up to 14, with optional whitespace around it. This covers negative and positive offsets, offsets after a fraction, and offsets after a time without seconds. Positive offsets andZused to giveNAwith a warning, and now give the instant SQLite reads. A TIME with an offset becomes a time of day in UTC and wraps around midnight, astime()does:'23:00:00-02:00'reads as 01:00:00. The time before the offset must be one thattime()accepts:HH:MM[:SS[.SSS]], with hours up to 24 (hour 24 only as 24:00:00). Durations such as'25:00:00-02:00'or'-01:00:00+00:00'therefore giveNAwith a warning, and'24:00:00+00:00'reads as 00:00:00, as intime(). Without an offset, a TIME is still a duration, so'24:00:00'stays 24 hours. The Extended Types section of?SQLitenow describes the offset. If anything else after the time starts with a sign orZ, such as-0500or-15:00, the value isNAwith the usual warning, which matches SQLite returningNULLfor it. Text without an offset parses exactly as before. The offset is applied as SQLite applies it, but the time before it is still read by boost, which accepts some text that SQLite rejects, such as12:00:60(#887, already onmain).Out of scope: DATE columns, a
Tbetween date and time, and a trailingUTC. These still giveNAwith a warning, as before. #394 would replace the boost parser altogether.Tests: four new
test_that()blocks intests/testthat/test-extendedTypes.R. They read offsets in DATETIME and TIME columns, compare the result with SQLite'sdatetime()andtime()on the same rows, and check that the offsets and TIME values SQLite rejects giveNAwith a warning. All four fail onmainand pass with this change.devtools::test()withNOT_CRAN=truegives no new failures. Thetest-httpvfs.Rerrors happen onmainas well (#832, #837).R CMD check --no-manualreports only a NOTE about the worktree's.gitfile.Where it sits: this is based on
main, outside the Arrow stack. The Arrow arrays of #861 share this parser and pin today's misreadings in their tests. Once this is merged up, #861 needs its expectations updated, and the parsing helpers it adds need the same offset handling.Review and limitations: review, Accepted limitations.
Closes #877.
Coordinating session: https://claude.ai/code/session_01Hr1rd7mthffYErGmWTGDfQ
Generated by Claude Code