Skip to content

fix: Return NA for zero and partial zero dates - #598

Merged
krlmlr merged 2 commits into
mainfrom
claude/zero-dates
Nov 29, 2026
Merged

krlmlr merged 2 commits into
mainfrom
claude/zero-dates

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Closes #595.

MariaRow::value_date() and MariaRow::value_date_time() now return NA_real_ when the year, month or day of the MYSQL_TIME is 0. Zero dates (0000-00-00) and partial zero dates (2020-00-00) are allowed with a permissive sql_mode. They were passed to days_from_civil() as is and came back as year -1. TIME values are unaffected.

New tests/testthat/test-zero-dates.R covers DATE, DATETIME and TIMESTAMP with sql_mode = '': zero and partial zero values give NA, including a zero date with a non-zero time (0000-00-00 12:00:00), and a valid value is unchanged. It does not test a partial zero TIMESTAMP, because the server may reject it. The full suite passes locally against MariaDB 10.11.

This touches the same function that the ALTREP redesign in #587 rewrites. The check will be carried over there.

https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS


Generated by Claude Code

DATE, DATETIME and TIMESTAMP values with a zero year, month, or day
are not valid dates and were converted to nonsensical values.
They are now returned as `NA`.
TIME values are unaffected.

Closes #595

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS
@krlmlr
krlmlr marked this pull request as ready for review November 29, 2026 12:01
@krlmlr
krlmlr merged commit 0c54f49 into main Nov 29, 2026
9 checks passed
@krlmlr
krlmlr deleted the claude/zero-dates branch November 29, 2026 14:00
krlmlr pushed a commit that referenced this pull request Nov 29, 2026
Resolve the conflict in src/MariaRow.cpp by keeping this branch's version,
which no longer converts MYSQL_TIME values.
Port the zero-date rule of #598 to MariaChunk::value_real(),
which serves element access, regions, and materialization of DATE and DATETIME columns:
a year, month, or day of 0 yields NA, TIME is unaffected.
Add a test that reads zero dates from the unconverted ALTREP columns
by element access and after materialization.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zero dates (0000-00-00) are returned as garbage instead of NA

2 participants