Skip to content

feat: add native JSON type support for SQL Server 2025#315

Open
dlevy-msft-sql wants to merge 1 commit into
microsoft:mainfrom
dlevy-msft-sql:feature/json-type
Open

feat: add native JSON type support for SQL Server 2025#315
dlevy-msft-sql wants to merge 1 commit into
microsoft:mainfrom
dlevy-msft-sql:feature/json-type

Conversation

@dlevy-msft-sql
Copy link
Copy Markdown

@dlevy-msft-sql dlevy-msft-sql commented Jan 31, 2026

Adds native JSON type support for SQL Server 2025 Preview, enabling proper handling of the new JSON data type.

Features

  • Add JSON token type (typeJson = 0xF4) and type parsing
  • Add featureExtJsonSupport for TDS login negotiation
  • Track JSON support capability in session state
  • Sort feature extensions for deterministic login packets
  • Comprehensive tests for JSON type scanning

Usage

JSON data is returned as string containing the JSON document. Supports scanning into:

  • string
  • []byte
  • mssql.NullJSON (wraps json.RawMessage)
  • Types implementing sql.Scanner

Requirements

  • SQL Server 2025 Preview or later

Split from #306 for easier review

@dlevy-msft-sql dlevy-msft-sql self-assigned this Jan 31, 2026
@dlevy-msft-sql dlevy-msft-sql added enhancement New feature or request Area - data types Issues related to data types Size: S Small issue (less than one week effort, less than 250 lines of code) labels Jan 31, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end support for SQL Server 2025’s native JSON type, including TDS login feature negotiation, session capability tracking, JSON parameter declaration behavior with fallback, and tests/docs.

Changes:

  • Introduces typeJson handling in TDS type parsing/metadata and SQL type name/decl generation.
  • Adds featExtJSONSUPPORT negotiation in LOGIN7 and tracks jsonSupported on the session.
  • Adds mssql.JSON / mssql.NullJSON parameter types plus a comprehensive JSON test suite and documentation updates.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
types.go Adds JSON type ID, PLP decode path, and type metadata helpers (decl/name/length/prec-scale).
token.go Parses server ACK payload for JSON feature extension.
tds.go Adds JSON feature-ext request/ACK handling, session flag, and deterministic feature-ext ordering.
tds_login_test.go Updates expected LOGIN7 hex blobs to include JSON feature extension and new deterministic ordering.
mssql_go19.go Adds JSON/NullJSON types and parameter encoding with JSON-decl fallback logic.
mssql.go Ensures JSON parameters are handled before driver.Valuer processing.
json_test.go Adds unit + integration tests for JSON parameter behavior, fallback behavior, and declarations.
README.md Documents JSON parameter types, compatibility/fallback behavior, and limitations.
CHANGELOG.md Adds release note entry for JSON support.

Comment thread json_test.go Outdated
Comment thread json_test.go Outdated
Comment thread json_test.go Outdated
Comment thread json_test.go Outdated
Comment thread CHANGELOG.md Outdated
Comment thread types.go
Comment thread mssql.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread mssql.go Outdated
Comment thread mssql_go19.go
Comment thread tds.go Outdated
Comment thread mssql.go Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.62%. Comparing base (65e137f) to head (567c8de).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main     #315       +/-   ##
===========================================
+ Coverage   80.62%   96.62%   +15.99%     
===========================================
  Files          35       92       +57     
  Lines        6910    74509    +67599     
===========================================
+ Hits         5571    71991    +66420     
- Misses       1068     2183     +1115     
- Partials      271      335       +64     
Flag Coverage Δ
unittests 96.55% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
bulkcopy.go 64.40% <100.00%> (+1.35%) ⬆️
mssql.go 89.43% <100.00%> (-0.02%) ⬇️
mssql_go19.go 96.56% <100.00%> (+1.58%) ⬆️
tds.go 70.58% <100.00%> (+1.23%) ⬆️
token.go 70.09% <100.00%> (+0.56%) ⬆️
types.go 82.39% <100.00%> (+0.31%) ⬆️

... and 57 files with indirect coverage changes

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread CHANGELOG.md Outdated
Comment thread mssql_go19.go Outdated
Comment thread types.go
Comment thread types.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread json_test.go Outdated
Comment thread token_test.go Outdated
Comment thread token_test.go Outdated
Comment thread json_test.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 17 changed files in this pull request and generated 1 comment.

Comment thread types.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 17 changed files in this pull request and generated 2 comments.

Comment thread json_test.go
Comment thread types.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 17 changed files in this pull request and generated 2 comments.

Comment thread mssql.go Outdated
Comment thread types.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 17 changed files in this pull request and generated 1 comment.

Comment thread json_test.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread types.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread json_test.go
Comment thread tds_login_test.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread json_test.go
Comment thread json_test.go
Comment thread json_test.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread types.go Outdated
Comment thread tds.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread mssql_go19.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

@dlevy-msft-sql dlevy-msft-sql requested a review from Copilot April 26, 2026 23:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread mssql_go19.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread mssql_go19.go Outdated
Comment thread mssql_go19.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread json_test.go Outdated
Comment thread mssql_go19.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread mssql_go19.go
Comment thread mssql_go19.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread json_test.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread bulkcopy.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread bulkcopy.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread tds.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

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.

3 participants