Skip to content

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

Open
gargsaumya wants to merge 1 commit into
mainfrom
saumya/gh667-bulkcopy-udt-e2e
Open

CHORE: e2e bulk copy into a CLR UDT column (GH-667)#683
gargsaumya wants to merge 1 commit 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
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

2 participants