-
Notifications
You must be signed in to change notification settings - Fork 295
Support XML data type for MSSQL #3006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: JerryNixon <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for SQL Server's XML data type by treating it as a string type, consistent with how SQL Server emits XML content via FOR JSON.
- Marks XML as a supported SQL type in
SqlTypeConstants.cs - Maps
SqlDbType.Xmltotypeof(string)inTypeHelper.cs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Core/Models/SqlTypeConstants.cs | Marks xml type as supported (changed from false to true) |
| src/Core/Services/TypeHelper.cs | Adds mapping from SqlDbType.Xml to typeof(string) in the type conversion dictionary |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this 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 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [SqlDbType.VarBinary] = typeof(byte[]), | ||
| [SqlDbType.VarChar] = typeof(string) | ||
| [SqlDbType.VarChar] = typeof(string), | ||
| [SqlDbType.Xml] = typeof(string) |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding an XML column to the type_table in the test database schema (DatabaseSchema-MsSql.sql) to enable integration testing of XML data type operations. While the unit tests in CLRtoJsonValueTypeUnitTests will validate the type mapping, integration tests would verify actual CRUD operations with XML data.
For example, add to the type_table schema:
xml_types xmlAnd include test data:
INSERT INTO type_table(..., xml_types) VALUES (..., '<doc><type>report</type></doc>')There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 3ce04b9. The type_table now includes an xml_types xml column with test data:
<doc><type>report</type></doc><author>admin</author><metadata><key>value</key></metadata><config><setting enabled="true"/></config>NULL(for row 5)
Co-authored-by: JerryNixon <[email protected]>
Why make this change?
Closes #2698
SQL Server's
XMLdata type (supported since SQL Server 2005) was not recognized by DAB, preventing use of tables with XML columns.What is this change?
Treat
XMLas a string type, consistent with how SQL Server emits it viaFOR JSON:xmlas supported (true)SqlDbType.Xml→typeof(string)xml_typescolumn totype_tablewith test data for integration testingDAB passes XML as string in both directions; SQL Server handles validation.
How was this tested?
Existing
CLRtoJsonValueTypeUnitTestsnow validates(xml,True)test case passes. Added XML column totype_tablein MsSql test database schema with various XML test data to enable integration testing of XML data type operations.Sample Request(s)
Response:
{ "value": [ { "id": 1, "metadata": "<author>admin</author>" } ] }Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.