[Phase 2] Enable MSSQL JSON data type - type mapping & error codes (engine)#3691
Open
souvikghosh04 wants to merge 1 commit into
Open
[Phase 2] Enable MSSQL JSON data type - type mapping & error codes (engine)#3691souvikghosh04 wants to merge 1 commit into
souvikghosh04 wants to merge 1 commit into
Conversation
4edabac to
6bed2da
Compare
…s (Phase 2) Treat SQL Server 2025+ JSON columns exactly like string columns (2026-06-09 design, issue #2768). Engine-only change validated by unit tests. - TypeHelper._sqlDbTypeToType[SqlDbType.Json] = typeof(string) (T004) - SqlTypeConstants: register json as supported literal (T004) - MsSqlDbExceptionParser BadRequestExceptionCodes += 13608-13614 so SQL JSON errors map to HTTP 400 (T006) - unit tests for json type mapping and 400 error mapping (T005/T007) The profiles DB fixture (T002) and Profile config entity (T003) are DEFERRED to Phase 3: the native json type requires SQL Server 2025+/Azure SQL and cannot be created on the LocalDB engine used by CI. They ship with the Phase 3 integration tests behind server-version gating. No changes to PostgreSQL/MySQL/DwSql/CosmosDB (FR-012).
6bed2da to
9e5a38d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds SQL Server 2025 JSON column support by treating JSON exactly like a string in DAB’s type system, and improves error handling so SQL JSON validation failures map to a client error instead of a generic server error.
Changes:
- Map
SqlDbType.Json(and the"json"type literal) to CLRstringso existing string read/write/filter/sort paths apply. - Map SQL Server JSON validation error codes (13608–13614) to HTTP 400 (Bad Request) in the MSSQL exception parser.
- Add/extend tests validating the new type mapping and HTTP status mapping.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Core/Services/TypeHelper.cs | Adds SqlDbType.Json -> string mapping so JSON behaves like a string in CLR/type resolution. |
| src/Core/Models/SqlTypeConstants.cs | Marks "json" as a supported SQL type literal for metadata/type-resolution test coverage. |
| src/Core/Resolvers/MsSqlDbExceptionParser.cs | Adds JSON validation error codes to the “bad request” classification. |
| src/Service.Tests/OpenApiDocumentor/CLRtoJsonValueTypeUnitTests.cs | Adds a targeted test asserting "json" resolves to string and maps to JsonDataType.String. |
| src/Service.Tests/UnitTests/DbExceptionParserUnitTests.cs | Adds a data-driven test asserting JSON validation errors map to HTTP 400. |
Comment on lines
+33
to
+36
| "4457", "4933", "4934", "4936", "4988", "8102", | ||
| // JSON data type validation errors (SQL Server 2025+). Invalid JSON | ||
| // supplied for a json column is a client error, mapped to HTTP 400. | ||
| "13608", "13609", "13610", "13611", "13612", "13613", "13614" |
Comment on lines
+130
to
+133
| Assert.AreEqual( | ||
| System.Net.HttpStatusCode.BadRequest, | ||
| dbExceptionParser.GetHttpStatusCodeForException(SqlTestHelper.CreateSqlException(number))); | ||
| } |
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.
What this PR does
Adds support for the SQL Server 2025
JSONcolumn type by treating it exactly like a normal text (string) column. Reading, writing, filtering, and sorting all reuse the paths DAB already has for strings — no new type, no special handling.The change
Two small edits to the engine:
JSONcolumn is astring.Both are covered by new unit tests.
This PR is intentionally scoped to just the engine change. The database test table and end-to-end (REST/GraphQL) tests are not included here because they need a real SQL Server 2025 database — and our CI currently runs on LocalDB, which doesn't understand the
JSONtype yet. Those tests come in the next phase.Delivery plan
Notes
JSONdata type for MSSQL #2768.