Skip to content

CHORE: e2e bulk copy into a CLR UDT column (GH-667) - #683

Merged
gargsaumya merged 3 commits into
mainfrom
saumya/gh667-bulkcopy-udt-e2e
Jul 28, 2026
Merged

CHORE: e2e bulk copy into a CLR UDT column (GH-667)#683
gargsaumya merged 3 commits into
mainfrom
saumya/gh667-bulkcopy-udt-e2e

Conversation

@gargsaumya

@gargsaumya gargsaumya commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Adds an end-to-end bulkcopy test for CLR UDT columns (GH-667).

Summary

What

test_bulkcopy_udt_geometry seeds a geometry column, reads the serialized UDT bytes back, bulk copies them into a second geometry column, and asserts a byte-exact round-trip (including a NULL row).

The built-in geometry CLR UDT travels the identical TDS 0xF0 wire path as custom UDTs (which require a deployed assembly, impractical in CI), so it faithfully exercises the fixed path.

Why

Before the fix, cursor.bulkcopy() into any UDT column failed - first with a malformed varbinary(-1) / Unsupported TDS type for bulk copy: 0xF0, and (once the wire mapping was fixed) with a target SQL type is Udt value-coercion error.

Dependency

This test requires the GH-667 fix in mssql_py_core (microsoft/mssql-rs#111), which contains two parts:

  1. mssql-tds: map UDT to varbinary(max) for the bulk-copy wire type / COLMETADATA / statement text.
  2. mssql-py-core: accept bytes -> UDT in bulk-copy value coercion.

Validated locally end-to-end against SQL Server with a py-core built from that branch. This should land together with the mssql-py-core version bump that ships the fix (the maintainers will handle the bump).

Related: microsoft/mssql-rs#111 · Fixes #667

Copilot AI review requested due to automatic review settings July 16, 2026 12:17
@gargsaumya gargsaumya changed the title test: e2e bulk copy into a CLR UDT column (GH-667) CHORE: e2e bulk copy into a CLR UDT column (GH-667) Jul 16, 2026
Adds an end-to-end bulkcopy test using the built-in geometry CLR UDT (same 0xF0 wire path as custom UDTs, which need a deployed assembly). Seeds a geometry column, reads the serialized UDT bytes, bulk copies them into a second geometry column, and asserts a byte-exact round-trip including a NULL. Requires the GH-667 fix in mssql_py_core (microsoft/mssql-rs#111): the varbinary(max) wire mapping plus bytes->UDT value coercion. Lands with the mssql-py-core version bump.
@gargsaumya
gargsaumya force-pushed the saumya/gh667-bulkcopy-udt-e2e branch from d6b27fb to f389d0c Compare July 16, 2026 12:19

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

Adds an end-to-end regression test to validate that cursor.bulkcopy() can insert CLR UDT values (via the built-in geometry type) by round-tripping the UDT’s serialized bytes, covering both non-NULL and NULL rows. This extends the bulkcopy integration suite to exercise the TDS 0xF0 (UDT) wire path via mssql_py_core.

Changes:

  • Add test_bulkcopy_udt_geometry to seed geometry values, fetch their serialized form, bulk copy into a second geometry column, and assert byte-exact equality.
  • Ensure the test explicitly covers a NULL row alongside non-NULL UDT values.

Comment thread tests/test_019_bulkcopy.py
@github-actions github-actions Bot added the pr-size: small Minimal code update label Jul 16, 2026

@bewithgaurav bewithgaurav left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

will the tests pass on vbump @gargsaumya ? approved

@gargsaumya

Copy link
Copy Markdown
Contributor Author

will the tests pass on vbump @gargsaumya ? approved

yes Gaurav

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

81%


📈 Total Lines Covered: 7068 out of 8676
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 59.9%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 76.3%
mssql_python.__init__.py: 77.3%
mssql_python.row.py: 77.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 81.4%
mssql_python.pybind.connection.connection.cpp: 83.7%
mssql_python.connection.py: 84.7%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

@gargsaumya
gargsaumya merged commit 4bc56b4 into main Jul 28, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cursor.bulkcopy() cannot load custom (non-spatial) CLR UDT columns

4 participants