Skip to content

Tests | Add collation transcoding tests#4051

Merged
cheenamalhotra merged 2 commits intodotnet:mainfrom
edwardneal:tests/collation-transcoding-tests
Apr 8, 2026
Merged

Tests | Add collation transcoding tests#4051
cheenamalhotra merged 2 commits intodotnet:mainfrom
edwardneal:tests/collation-transcoding-tests

Conversation

@edwardneal
Copy link
Copy Markdown
Contributor

Description

This PR replaces one test and introduces another.

CollatedDataReaderTest

Previously, CollatedDataReaderTest would create a brand new database with one of two collations (Kazakh_90_CI_AI and Georgian_Modern_Sort_CI_AS), then try to select an ASCII string from it. This had a few issues:

  • It only tested two collations and two code pages
  • The permissions needed to create a new database precluded an Azure SQL instance
  • The ASCII string was a very generous test case. It verified a string containing characters which are present in every code page

I've replaced this with something a little more robust. We now test every collation on a SQL instance, retrieving the character string and its byte representation, then we make sure that they roundtrip. It also uses a string containing the é character; this isn't present in Kazakh_90_CI_AI's code page, so SQL Server converts it to e. This is legitimate behaviour which would otherwise have failed.

CollatedStringInOutputParameter_DecodesSuccessfully

This is a new test which proves that we can roundtrip non-ASCII characters in output parameters when the value's collation's code page represents these non-ASCII characters differently: the default English Windows code page represents é as 0xE9; code page 936 represents this as [0xA8, 0xA6]; and UTF8 represents this as [0xC3, 0xA9].

Issues

Loosely related: #584 originally added the CollatedDataReaderTest test, and referred to making sure that the driver would maintain the collation/codepage mappings. These two tests provide sufficient test coverage for that effort (which would also unblock globalization invariant mode.)

Testing

New tests run, the other tests and code remain untouched.

This previously only tested Kazakh_90_CI_AI and Georgian_Modern_Sort_CI_AS. The replacement tests every collation.
It also performs a more comprehensive check that the string/byte[] roundtrips with the varbinary/varchar from the database instance.
Finally, it no longer requires permission to drop and create databases: we can just use the COLLATE statement.
@cheenamalhotra cheenamalhotra added the Area\Tests Issues that are targeted to tests or test projects label Mar 16, 2026
@cheenamalhotra cheenamalhotra added this to the 7.1.0-preview1 milestone Mar 16, 2026
@benrr101 benrr101 moved this from To triage to In progress in SqlClient Board Mar 17, 2026
@benrr101 benrr101 moved this from In progress to In review in SqlClient Board Mar 17, 2026
@paulmedynski
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski paulmedynski self-assigned this Mar 25, 2026
@paulmedynski paulmedynski modified the milestone: 7.1.0-preview1 Mar 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.56%. Comparing base (14b96a2) to head (c4be946).
⚠️ Report is 48 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (14b96a2) and HEAD (c4be946). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (14b96a2) HEAD (c4be946)
CI-SqlClient 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4051      +/-   ##
==========================================
- Coverage   74.62%   65.56%   -9.07%     
==========================================
  Files         280      274       -6     
  Lines       43814    66778   +22964     
==========================================
+ Hits        32698    43785   +11087     
- Misses      11116    22993   +11877     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 65.56% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@cheenamalhotra cheenamalhotra left a comment

Choose a reason for hiding this comment

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

Very important test for encoding validation. Thanks!

@cheenamalhotra cheenamalhotra merged commit d7fb5cb into dotnet:main Apr 8, 2026
299 of 300 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in SqlClient Board Apr 8, 2026
@edwardneal edwardneal deleted the tests/collation-transcoding-tests branch April 8, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area\Tests Issues that are targeted to tests or test projects

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants