Skip to content

Re-enable DateOnly/TimeOnly support, fixing the defects that got it disabled - #2228

Merged
mgravell merged 1 commit into
mainfrom
dateonly-read-coercion
Aug 20, 2026
Merged

mgravell merged 1 commit into
mainfrom
dateonly-read-coercion

Conversation

@mgravell

Copy link
Copy Markdown
Member

DateOnly/TimeOnly support (#2051) was compiled out in 907a4d9 pending #2071/#2072. This re-enables it with the root causes fixed, and teaches the read paths that the date/time family has no IConvertible bridge — which box a date/time column yields is a provider/version decision (Npgsql 10: DateOnly/TimeOnly; SqlClient and Npgsql 9: DateTime/TimeSpan), so both shapes must convert:

Verified with a 13-probe matrix across SqlClient and both Npgsql 9.0.2/10.0.2 (all green, both directions, nullable included, plus the exact #2072 repro shape), and the full test suite passes on net10/net8/net481 against local SQL Server + the documented Postgres container. The parked DateTimeOnlyTests are re-enabled with new tests for the #2072 and #2227 shapes and date-as-DateTime regression guards; PostgresqlTests gains the Npgsql-10 interchange matrix.

Fixes #2072, #2226, #2227, #1728; expected to also resolve #2071 (same family — would appreciate confirmation from that repro).

…isabled

DateOnly/TimeOnly support (#2051) was compiled out in 907a4d9 pending
#2071/#2072. This re-enables it with the root causes fixed, and teaches the
read paths that the date/time family has no IConvertible bridge - which box
a date or time column yields is a provider/version decision (Npgsql 10:
DateOnly/TimeOnly; SqlClient and Npgsql 9: DateTime/TimeSpan), so both
shapes must convert:

- GetFieldValue<T> is no longer demanded of a column whose reported type
  needs a family conversion (a datetime column into a DateOnly member was
  the #2072 breakage; SqlDecimal-style entries, where GetFieldValue from a
  differently-reported column is the whole point, keep it);
- the member, scalar and Parse<T> paths all convert DateOnly/TimeOnly <->
  DateTime/TimeSpan in both directions (IL for members, object-level
  elsewhere), fixing reads against Npgsql 10 date/time columns (#2226);
- Query<DateOnly>/<TimeOnly> in scalar form no longer silently return
  default(T) (#2227): the typeMap entries make them simple types again;
- the same-TypeCode direct-unbox shortcut is restricted to distinct codes:
  TypeCode.Object matching TypeCode.Object says nothing (TimeSpan into
  TimeOnly? threw), while object on either side (sql_variant columns,
  dynamic members) keeps the direct unbox;
- the scalar conversion fallback keeps Convert.ChangeType's strict null
  contract (TestConversionExceptionMessages pins it).

The parked DateTimeOnlyTests are re-enabled, with new tests for the #2072
shape (datetime column into DateOnly member), the #2227 scalar shape, and
date-as-DateTime regression guards; PostgresqlTests gains the Npgsql-10
interchange matrix ([FactPostgresql], so it runs where the documented
container is available).

Fixes #2072, #2226, #2227, #1728; expected to also resolve #2071.
@mgravell
mgravell merged commit 6d48ef6 into main Aug 20, 2026
2 checks passed
@RobK410

RobK410 commented Aug 20, 2026

Copy link
Copy Markdown

Thank you!

This was referenced Sep 12, 2026
mgravell added a commit that referenced this pull request Sep 23, 2026
…2238)

main.yml filtered pushes with

  paths:
  - '*'
  - '!/docs/*'

GitHub's `*` does not cross a '/', so `'*'` matches only files at the repository
root. Any push touching just Dapper/, tests/ or another subdirectory failed the
filter and the build was skipped - silently, because a skipped workflow is not a
failure. Checking main:

  8becae8 (#2230)  4 root files  ran
  2ca8261 (#2223)  1 root file   ran
  6d48ef6 (#2228)  0 root files  skipped
  41d76c7 (#2225)  0 root files  skipped

So most merges to main never built at all. The second line never worked either:
path filters are repo-relative and take no leading slash, so '!/docs/*' matched
nothing - the docs exclusion it was written for was already being done, by
accident, by the '*' that excluded every subdirectory.

paths-ignore: 'docs/**' says what was meant: run for everything except a
docs-only change.

This matters more than it used to. release.yml takes its version from what a
green main run reports, so a main build that never runs means no version to tag
with - which is how this was noticed.
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.

DateOnly "off by one" column error Problem with DateOnly mapping when updating form v2.1.35 to 2.1.44

2 participants