Skip to content

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

Open
dlevy-msft-sql wants to merge 1 commit intomicrosoft: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 intomicrosoft:mainfrom
dlevy-msft-sql:feature/json-type

Conversation

@dlevy-msft-sql
Copy link

@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

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.

Copy link

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.

@codecov-commenter
Copy link

codecov-commenter commented Jan 31, 2026

Codecov Report

❌ Patch coverage is 85.81560% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.64%. Comparing base (c16a19e) to head (7e860f9).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
types.go 72.72% 9 Missing ⚠️
tds.go 70.37% 7 Missing and 1 partial ⚠️
mssql_go19.go 95.58% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #315      +/-   ##
==========================================
+ Coverage   75.36%   78.64%   +3.27%     
==========================================
  Files          34       34              
  Lines        6597     6728     +131     
==========================================
+ Hits         4972     5291     +319     
+ Misses       1337     1155     -182     
+ Partials      288      282       -6     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

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.

Copy link

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.

Copy link

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.

Copy link

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.

Copy link

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.

Copy link

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.

Copy link

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.

Copy link

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.

Copy link

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.

Copy link

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 no new comments.

@dlevy-msft-sql dlevy-msft-sql marked this pull request as ready for review February 2, 2026 02:24
@dlevy-msft-sql dlevy-msft-sql added in-review Size: L Large issue (four or more weeks effort, less than 2500 lines of code) Priority: 1 High priority/impact Priority: 2 Medium priority/impact and removed Size: S Small issue (less than one week effort, less than 250 lines of code) Priority: 1 High priority/impact labels Feb 2, 2026
@dlevy-msft-sql dlevy-msft-sql changed the title feat: Add native JSON type support for SQL Server 2025 feat: add native JSON type support for SQL Server 2025 Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - data types Issues related to data types enhancement New feature or request Priority: 2 Medium priority/impact Size: L Large issue (four or more weeks effort, less than 2500 lines of code)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants