[Phase 3] MSSQL JSON - test fixture + REST CRUD tests - #3720
Merged
Conversation
Mirrors the merged vector-type feature (#3677). CI now runs SQL Server 2025 (#3697), so the native json column is created unconditionally - no server-version gating needed. - profiles table (id, metadata json) + 5 seed rows (simple/array/nested/unicode/null) (T002) - Profile entity in dab-config.MsSql.json + config-generator command, REST + GraphQL enabled, anon/authenticated CRUD (T003) - MsSqlRestJsonTypesTests: GET list/by-pk/null/array/nested/unicode, POST, PUT, PATCH, PATCH-to-null, DELETE (T011,T013,T015,T017,T019)
souvikghosh04
marked this pull request as ready for review
July 14, 2026 13:17
souvikghosh04
requested review from
Alekhya-Polavarapu,
Aniruddh25,
JerryNixon,
RubenCerna2079,
aaronburtle,
anushakolan,
rusamant,
sourabh1007,
stuartpa and
vadeveka
as code owners
July 14, 2026 13:17
Contributor
There was a problem hiding this comment.
Pull request overview
Adds SQL Server 2025 native JSON end-to-end coverage to the MSSQL integration test suite by extending the MsSql schema fixture, test config, and adding REST CRUD tests for the new profiles.metadata (json) column. This fits into the existing pattern used for recently-added SQL Server 2025-only datatypes (e.g., vector) to validate behavior through the REST API.
Changes:
- Add
profilestable with ajsoncolumn and seeded rows to the MSSQL test schema. - Add
Profileentity to the MSSQL test config and config-generator command list. - Add REST integration tests covering read + CRUD mutations for JSON values (semantic comparison via JSON parsing).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Service.Tests/SqlTests/RestApiTests/MsSqlRestJsonTypesTests.cs | New REST integration test suite validating JSON column round-tripping (read + CRUD). |
| src/Service.Tests/DatabaseSchema-MsSql.sql | Adds profiles table and seed data for JSON scenarios. |
| src/Service.Tests/dab-config.MsSql.json | Adds Profile entity mapping for REST/GraphQL. |
| config-generators/mssql-commands.txt | Adds generator commands to reproduce the Profile entity config. |
…les seed The vector_type_table block left IDENTITY_INSERT ON (it was previously the last such block). Inserting the profiles seed after it triggered 'IDENTITY_INSERT is already ON for table vector_type_table', aborting schema init for the whole MsSql suite. Turn vector OFF before the profiles ON/OFF block.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Align profiles identity seed to IDENTITY(5001, 1) per the schema convention (line 74) - Tighten ParseMetadata to assert metadata is a JSON string (proves the Phase 2 string-contract), no raw-object fallback - GetJsonTypeList now asserts each row metadata is a JSON string or null - Fix PatchJsonType_ToNull doc comment to reference id/2
…snapshot CI on SQL Server 2025 shows a native json column is inlined by DAB's FOR JSON PATH projection as a nested JSON object (like vector columns become native arrays), not an escaped string. DAB applies no special handling - SQL Server inlines it. Correct the read-side assertions accordingly: - ParseMetadata now asserts metadata.ValueKind == Object and returns it directly (no string parse). - GetJsonTypeList asserts each row metadata is a JSON object or null. - Update doc comments to describe the FOR JSON PATH inlining behavior. Also refresh ConfigurationTests.TestReadingRuntimeConfigForMsSql.verified.txt to include the new Profile entity (only delta).
…op key-fields) CI regenerates dab-config.MsSql.json from config-generators/mssql-commands.txt before running tests. The 'add Profile' command specifies no --source.key-fields (profiles is a table, so the PK is inferred from the DB schema, consistent with VectorType and every other table entity). The hand-added key-fields made the committed config - and the verified snapshot - diverge from the generated config, so TestReadingRuntimeConfigForMsSql failed on CI (Source.KeyFields present in verified, absent in the generated config it deserializes). Remove key-fields from the Profile source and refresh the snapshot to match.
aaronburtle
reviewed
Jul 22, 2026
Per review: PutJsonType_Update, PatchJsonType_Update, and PatchJsonType_ToNull mutate shared rows (id 1/2) and restore afterwards. If an assertion failed before the restore, the row stayed corrupted for later tests. Wrap mutate/assert in try and move the restore into finally so the row is always reset.
Aniruddh25
approved these changes
Jul 27, 2026
This was referenced Jul 28, 2026
souvikghosh04
added a commit
that referenced
this pull request
Jul 30, 2026
…QL tests (#3738) ## Why Part of MSSQL native `JSON` support (#2768). Started as Phase 3b **schema-discovery tests**, but review (thanks @aaronburtle) surfaced a real product inconsistency that this PR now also fixes. **The problem:** #2768 requires a `JSON` column to be treated as a normal `string` for **input and output**. But the MSSQL read path (`FOR JSON PATH`) was *inlining* a native `json` column as a nested JSON **object**. Consequences: - REST returned `"metadata": {"role":"admin"}` (object) instead of `"metadata": "{\"role\":\"admin\"}"` (string). - A GraphQL read of the `String`-typed field threw a `GraphQLMapping` error — the `String` leaf resolver calls `JsonElement.GetString()`, which fails on an object. So schema introspection could pass while `profile_by_pk(id:1){ metadata }` failed at runtime. - OpenAPI/GraphQL advertised `string`, contradicting the object runtime — generated clients would mis-model the field. ## What **Engine fix** (`MsSqlQueryBuilder`): the read path now casts a native `json` column (`SqlDbType.Json`) to `NVARCHAR(MAX)` in `WrappedColumns`, so `FOR JSON PATH` emits it as an escaped JSON **string** rather than inlining it as an object. This is the single choke point for REST **and** GraphQL reads. Regular `nvarchar` columns are untouched. Mutations already return `json` as a string via the tabular `OUTPUT` clause, so no change was needed there. **Tests:** | Layer | Test | Asserts | |------|------|---------| | OpenAPI | `JsonTypeSchemaTests` | `metadata` is `type: string` with no `format` in the **response** and both **request-body** schemas (`Profile_NoAutoPK` for POST, `Profile_NoPK` for PUT/PATCH) | | GraphQL introspection | `MsSqlGraphQLJsonSchemaTests` | `Profile.metadata` is the built-in `String` scalar (no custom JSON scalar) | | GraphQL read (new) | `MsSqlGraphQLJsonSchemaTests` | `profile_by_pk(id:1){ metadata }` returns the payload as a JSON **string** — guards against introspection passing while a real read throws | | REST | `MsSqlRestJsonTypesTests` (updated) | flipped back to the string contract: `metadata` is returned as a JSON **string** (`ParseMetadata`/`GetJsonTypeList` assert `JsonValueKind.String`) | > Note: DAB's OpenAPI documentor does not emit `Nullable` on the property schema for **any** column type, so the schema tests assert `type: string` + no `format` (not nullability). ## Intentionally omitted - **MCP `describe_entities` (T010)**: it projects only the config field `name`/`description`, not DB column data types, so there is no JSON-specific behavior to assert. ## Notes - **This PR now includes a product (engine) change**, not tests only. - Requires SQL Server 2025 / Azure SQL (native `json`); CI already runs SQL 2025. - Cannot be run locally (no SQL 2025 here) — relying on CI. ## Delivery plan | Phase | What | Status | |-------|------|--------| | 1 | .NET 10 + SqlClient 6.x | ✅ Merged (#3697/#3656) | | 2 | JSON type + error mapping (engine) | ✅ Merged (#3691) | | 3 | Test fixture + REST CRUD tests | ✅ Merged (#3720) | | **3b** | **json-as-string read fix + OpenAPI/GraphQL discovery & read tests (this PR)** | 🚧 | | 4 | Error/filter edge cases + regression + polish | Next |
This was referenced Aug 4, 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.
What this PR does
Adds the database test fixture and REST integration tests for SQL Server 2025
JSONcolumns. It builds on Phase 2 (which taught the engine to treatJSONas a normalstring) and proves the behavior end-to-end through the REST API.This follows the exact pattern of the recently merged vector data type feature (#3677), and is unblocked by CI now running SQL Server 2025 (#3697).
What's included
profilestable with anidand ametadata jsoncolumn, plus 5 seed rows covering a simple object, an array, a deeply nested object, unicode + emoji, andNULL.Profileentity (REST + GraphQL enabled) in the MsSql test config and config generator.MsSqlRestJsonTypesTests: read (list, by id, null, array, nested, unicode), insert, update (PUT/PATCH), clear-to-null, and delete.Because DAB treats
JSONas a string, the tests parsemetadataand compare it semantically, so they're robust to any whitespace / key-order normalization the engine applies.No gating needed
Unlike the earlier plan, the table is created unconditionally (no server-version guard) — CI runs SQL Server 2025 and the schema already uses the 2025-only
vectortype the same way.Delivery plan
Notes
jsontype).JSONdata type for MSSQL #2768.