Skip to content

Create datetime2 columns without the reported column size - #417

Merged
quinnj-bot[bot] merged 2 commits into
mainfrom
claude/load-datetime2
Nov 18, 2026
Merged

quinnj-bot[bot] merged 2 commits into
mainfrom
claude/load-datetime2

Conversation

@quinnj-bot

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

Copy link
Copy Markdown
Contributor

Why

On SQL Server, ODBC.load cannot create a table with a DateTime column. It emits datetime2(27), which SQL Server rejects with Specified scale 27 is invalid. load logs that as a warning, and every insert then fails with Invalid object name. SQL Server's type info lists datetime2 with the create parameter scale and a COLUMN_SIZE of 27, which is its display length. sqltype appended COLUMN_SIZE to any single-parameter type. A type whose only parameter is scale now keeps its default scale. For datetime2 that 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

  • sqltype no longer appends COLUMN_SIZE when CREATE_PARAMS is exactly scale.
  • test/sqlserver.jl loads a DateTime column and reads it back.

Scope

  • Only types whose lone create parameter is scale change. Among the drivers I checked, that is SQL Server datetime2, time, and datetimeoffset, and MariaDB TIMESTAMP, which load doesn't pick because DATETIME comes first.
  • Inserting a DateTime with milliseconds into SQL Server still fails, with 22008 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 TABLE text ODBC.load builds for these types changes. MariaDB, psqlODBC, and SQLite ODBC produce the same sqltype mapping as before. I checked all three.

Verification

  • SQL Server 2022 (Azure SQL Edge) with ODBC Driver 18: the new check errors on main with Specified scale 27 is invalid and then Invalid object name 'load_datetime'. On this branch, test/sqlserver.jl passes 16/16.
  • Full 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_SQLSERVER is set. MariaDB, the CI driver, never reaches this path.

🤖 Generated with Claude Code

quinnj and others added 2 commits November 18, 2026 01:17
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

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.27%. Comparing base (26c8b4b) to head (e299ab0).

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.
📢 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 72470c7 into main Nov 18, 2026
7 checks passed
@quinnj-bot
quinnj-bot Bot deleted the claude/load-datetime2 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