Skip to content

Bind DateTime parameters with millisecond precision - #418

Merged
quinnj-bot[bot] merged 2 commits into
mainfrom
claude/datetime-param-precision
Nov 18, 2026
Merged

quinnj-bot[bot] merged 2 commits into
mainfrom
claude/datetime-param-precision

Conversation

@quinnj-bot

@quinnj-bot quinnj-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Why

On SQL Server, any query or insert with a DateTime parameter that has milliseconds fails with 22008 Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding. That includes ODBC.load and executemany of such values. Every DateTime parameter declared 0 fractional digits. The columnsize and decimaldigits methods for timestamps took Vector{SQLTimestamp}, but parameter buffers are Vector{Union{Missing, SQLTimestamp}}, so those methods never ran and the generic fallback returned 0. DateTime parameters now declare yyyy-mm-dd hh:mm:ss.fff: ColumnSize 23 and DecimalDigits 3.

I found this while checking #375 (SQL Server, errors around ODBC.load), alongside #417.

What changed

  • The timestamp columnsize and decimaldigits methods take the buffer type parameters actually use, and return 23 and 3.
  • I removed Printf, which only the old DecimalDigits expression used.

Scope

  • Only DateTime parameters change. The other columnsize methods (integers, floats, Bool, Date, Time) never match a parameter buffer either, so they send 0. Drivers accept 0 for those types, so I left them.
  • DecFP parameters with fractional digits still fail on SQL Server, with 22001 String data, right truncation. They bind as SQL_DECIMAL text with DecimalDigits 0. That needs its own change.

Blast Radius

Every driver now receives ColumnSize 23 and DecimalDigits 3 for DateTime parameters instead of 0 and 0. MariaDB, psqlODBC, and SQLite ODBC store the same values as before. I checked each with a millisecond DateTime insert.

Verification

  • The new CI check, which tests the DecimalDigits a DateTime parameter declares, fails on main (0 == 3) and passes here.
  • SQL Server 2022 (Azure SQL Edge) with ODBC Driver 18: SELECT CAST(? AS datetime2(3)) with 05.678 errors on main with 22008 and round trips here. test/sqlserver.jl passes 16/16.
  • Full Pkg.test() passes on macOS (MariaDB Connector 3.1.22) with Julia 1.12 and 1.10.

🤖 Generated with Claude Code

quinnj and others added 2 commits November 18, 2026 01:20
A DateTime parameter binds with DecimalDigits 0, and SQL Server rejects
any fractional seconds with 22008 "Datetime field overflow".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The timestamp ColumnSize and DecimalDigits methods took
Vector{SQLTimestamp}, but parameter buffers are
Vector{Union{Missing, SQLTimestamp}}, so they never ran and every
DateTime parameter declared 0 fractional digits. SQL Server enforces
that and rejected any value with milliseconds. Declare
"yyyy-mm-dd hh:mm:ss.fff": ColumnSize 23, DecimalDigits 3.

Printf was used only by the old DecimalDigits expression.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.47%. Comparing base (26c8b4b) to head (abeb779).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #418      +/-   ##
==========================================
+ Coverage   84.20%   84.47%   +0.27%     
==========================================
  Files           7        7              
  Lines        1019     1024       +5     
==========================================
+ Hits          858      865       +7     
+ Misses        161      159       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@quinnj-bot
quinnj-bot Bot merged commit afe9085 into main Nov 18, 2026
7 checks passed
@quinnj-bot
quinnj-bot Bot deleted the claude/datetime-param-precision branch November 18, 2026 09:12
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.

1 participant