Repository navigation
Bind DateTime parameters with millisecond precision - #418
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On SQL Server, any query or insert with a
DateTimeparameter that has milliseconds fails with22008 Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding. That includesODBC.loadandexecutemanyof such values. EveryDateTimeparameter declared 0 fractional digits. Thecolumnsizeanddecimaldigitsmethods for timestamps tookVector{SQLTimestamp}, but parameter buffers areVector{Union{Missing, SQLTimestamp}}, so those methods never ran and the generic fallback returned 0.DateTimeparameters now declareyyyy-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
columnsizeanddecimaldigitsmethods take the buffer type parameters actually use, and return 23 and 3.Printf, which only the old DecimalDigits expression used.Scope
DateTimeparameters change. The othercolumnsizemethods (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.DecFPparameters with fractional digits still fail on SQL Server, with22001 String data, right truncation. They bind asSQL_DECIMALtext with DecimalDigits 0. That needs its own change.Blast Radius
Every driver now receives ColumnSize 23 and DecimalDigits 3 for
DateTimeparameters instead of 0 and 0. MariaDB, psqlODBC, and SQLite ODBC store the same values as before. I checked each with a millisecondDateTimeinsert.Verification
DateTimeparameter declares, fails on main (0 == 3) and passes here.SELECT CAST(? AS datetime2(3))with05.678errors on main with 22008 and round trips here.test/sqlserver.jlpasses 16/16.Pkg.test()passes on macOS (MariaDB Connector 3.1.22) with Julia 1.12 and 1.10.🤖 Generated with Claude Code