Repository navigation
Create datetime2 columns without the reported column size - #417
Merged
Merged
Conversation
ODBC.load creates the column as datetime2(27), and SQL Server rejects it with "Specified scale 27 is invalid". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SQL Server's SQLGetTypeInfo row for datetime2 has CREATE_PARAMS "scale" and COLUMN_SIZE 27, its display size. ODBC.load appended the column size as the type parameter, so every DateTime column failed to create. A type whose only parameter is a scale now keeps its default scale. 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 #417 +/- ##
==========================================
+ Coverage 84.20% 84.27% +0.07%
==========================================
Files 7 7
Lines 1019 1024 +5
==========================================
+ Hits 858 863 +5
Misses 161 161 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 18, 2026
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,
ODBC.loadcannot create a table with aDateTimecolumn. It emitsdatetime2(27), which SQL Server rejects withSpecified scale 27 is invalid.loadlogs that as a warning, and every insert then fails withInvalid object name. SQL Server's type info listsdatetime2with the create parameterscaleand a COLUMN_SIZE of 27, which is its display length.sqltypeappended COLUMN_SIZE to any single-parameter type. A type whose only parameter isscalenow keeps its default scale. Fordatetime2that default is 7 digits, which holds Julia's milliseconds.I found this while checking #375 (SQL Server, errors around
ODBC.load). The screenshot in that issue isn't readable as text, so I don't know whether this is the same error.What changed
sqltypeno longer appends COLUMN_SIZE when CREATE_PARAMS is exactlyscale.test/sqlserver.jlloads aDateTimecolumn and reads it back.Scope
scalechange. Among the drivers I checked, that is SQL Serverdatetime2,time, anddatetimeoffset, and MariaDBTIMESTAMP, whichloaddoesn't pick becauseDATETIMEcomes first.DateTimewith milliseconds into SQL Server still fails, with22008 Datetime field overflow. That is a separate parameter-binding bug, and I'm opening a separate PR for it. The new test uses whole seconds.Blast Radius
Only the
CREATE TABLEtextODBC.loadbuilds for these types changes. MariaDB, psqlODBC, and SQLite ODBC produce the samesqltypemapping as before. I checked all three.Verification
Specified scale 27 is invalidand thenInvalid object name 'load_datetime'. On this branch,test/sqlserver.jlpasses 16/16.Pkg.test()passes on macOS (MariaDB Connector 3.1.22) with Julia 1.12 and 1.10.CI has no SQL Server, so the new check runs only where
ODBC_TEST_SQLSERVERis set. MariaDB, the CI driver, never reaches this path.🤖 Generated with Claude Code