Skip to content

Globalization invariant mode: Require explicit LCID when constructing SqlMetaData#4457

Open
edwardneal wants to merge 1 commit into
dotnet:mainfrom
edwardneal:feat/sqlmetadata-globalization-invariant-mode
Open

Globalization invariant mode: Require explicit LCID when constructing SqlMetaData#4457
edwardneal wants to merge 1 commit into
dotnet:mainfrom
edwardneal:feat/sqlmetadata-globalization-invariant-mode

Conversation

@edwardneal

Copy link
Copy Markdown
Contributor

Description

SqlClient doesn't currently support globalization invariant mode, and we throw an exception whenever someone tries to use it in the main SqlConnection entry point. This PR closes a similar entry point when instantiating the SqlMetaData type.

I've explicitly been specific when closing entry points, in order to leave the door open to future support for this mode. The main reason why we can't support it was the requirement for LCID/codepage mapping, but this was removed as a secondary effect of #4212.

The result of this PR is that if globalization invariant mode is enabled, only four SqlMetaData constructors are permitted for columns of type Text / NText / Varchar / NVarchar / Char / NChar:

  • SqlMetaData(string name, SqlDbType dbType, long maxLength, byte precision, byte scale, long locale, SqlCompareOptions compareOptions, Type userDefinedType)
  • SqlMetaData(string name, SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, SqlCompareOptions compareOptions, Type userDefinedType, bool useServerDefault, bool isUniqueKey, SortOrder columnSortOrder, int sortOrdinal)
  • SqlMetaData(string name, SqlDbType dbType, long maxLength, long locale, SqlCompareOptions compareOptions, bool useServerDefault, bool isUniqueKey, SortOrder columnSortOrder, int sortOrdinal)
  • SqlMetaData(string name, SqlDbType dbType, long maxLength, long locale, SqlCompareOptions compareOptions)

These are permitted because they force the user to specify an LCID in the locale or the localeId parameter.

Issues

Stands alone, but also lays the groundwork for #3742.

Testing

Unit tests have been added alongside the existing ones (which are, in turn, in the wrong assembly - to be cleaned up in a follow-up PR.)

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@paulmedynski paulmedynski added this to the 7.1.0-preview3 milestone Jul 21, 2026
@paulmedynski paulmedynski added Public API 🆕 Issues/PRs that introduce new APIs to the driver. Approval Needed Issues/PRs that require approval from the maintainers before changes will be accepted. labels Jul 21, 2026
@paulmedynski paulmedynski moved this from To triage to Backlog in SqlClient Board Jul 21, 2026
@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

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

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.90%. Comparing base (fdebcd2) to head (3942f7b).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4457      +/-   ##
==========================================
- Coverage   65.83%   64.90%   -0.93%     
==========================================
  Files         287      287              
  Lines       43763    66970   +23207     
==========================================
+ Hits        28812    43469   +14657     
- Misses      14951    23501    +8550     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 64.90% <100.00%> (?)

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

☔ View full report in Codecov by Harness.
📢 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.

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

Labels

Approval Needed Issues/PRs that require approval from the maintainers before changes will be accepted. Public API 🆕 Issues/PRs that introduce new APIs to the driver.

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants