Skip to content

Support XML data type for MSSQL - #3006

Open
Jerry Nixon (JerryNixon) with Copilot wants to merge 16 commits into
mainfrom
copilot/support-xml-data-type-mssql
Open

Jerry Nixon (JerryNixon) with Copilot wants to merge 16 commits into
mainfrom
copilot/support-xml-data-type-mssql

Conversation

Copilot AI commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor

Why make this change?

SQL Server's XML data type (supported since SQL Server 2005) was not recognized by DAB, preventing use of tables with XML columns.

What is this change?

Treat XML as a string type, consistent with how SQL Server emits it via FOR JSON:

  • SqlTypeConstants.cs: Mark xml as supported (true)
  • TypeHelper.cs: Map SqlDbType.Xml → typeof(string)
  • DatabaseSchema-MsSql.sql: Add xml_types column to type_table with test data for integration testing
  • MsSqlDbExceptionParser.cs: Add xml parsing errors that come from SQL

DAB passes XML as string in both directions; SQL Server handles validation.

How was this tested?

  • Integration Tests
  • Unit Tests

Existing CLRtoJsonValueTypeUnitTests now validates (xml,True) test case passes. Added xml_types xml column to type_table in the MsSql test database schema with various XML test data to enable integration testing of XML data type operations.
Added tests to ensure all types of operations, work on the new xml data type for REST, GraphQL, & MCP.

Sample Request(s)

POST /documents
Content-Type: application/json

{
  "id": 1,
  "metadata": "<author>admin</author>"
}

Response:

{
  "value": [
    {
      "id": 1,
      "metadata": "<author>admin</author>"
    }
  ]
}

Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.Xml to typeof(string) in TypeHelper.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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved. Please check on the filtering/ordering scenarios on XML datatype columns

[SqlDbType.Vector] = typeof(float)
[SqlDbType.Vector] = typeof(float),
[SqlDbType.Xml] = typeof(string)
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to handle XML explicitly in filtering and ordering during queries? Do we have supporting tests covering those?

@RubenCerna2079

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

Add XML data type support for MSSQL

8 participants