Skip to content

Format vector floats with the invariant culture in SqlServerVectorTyp… - #38725

Open
ilkertskn wants to merge 1 commit into
dotnet:mainfrom
ilkertskn:fix/sqlserver-vector-type-mapping-culture
Open

Format vector floats with the invariant culture in SqlServerVectorTyp…#38725
ilkertskn wants to merge 1 commit into
dotnet:mainfrom
ilkertskn:fix/sqlserver-vector-type-mapping-culture

Conversation

@ilkertskn

@ilkertskn ilkertskn commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

…eMapping

  • GenerateNonNullSqlLiteral appended each float via StringBuilder.Append(float), which formats with the current culture, so a vector literal such as CAST('[1.5,2.5]' AS VECTOR(2)) became CAST('[1,5,2,5]' AS VECTOR(2)) under cultures with a comma decimal separator (e.g. de-DE)
  • Format each float with "R" and CultureInfo.InvariantCulture, matching FloatTypeMapping
  • Add a test under a non-invariant culture
  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:
        Summary of the changes
        - Detail 1
        - Detail 2

        Fixes #bugnumber
  • Tests for the changes have been added (for bug fixes / features)
  • Code follows the same patterns and style as existing code in this repo

…eMapping

- GenerateNonNullSqlLiteral appended each float via StringBuilder.Append(float), which formats with
  the current culture, so a vector literal such as CAST('[1.5,2.5]' AS VECTOR(2)) became
  CAST('[1,5,2,5]' AS VECTOR(2)) under cultures with a comma decimal separator (e.g. de-DE)
- Format each float with "R" and CultureInfo.InvariantCulture, matching FloatTypeMapping
- Add a test under a non-invariant culture
@ilkertskn
ilkertskn requested a review from a team as a code owner July 30, 2026 21:52
@ilkertskn

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes SQL Server vector SQL literal generation to be culture-invariant when formatting float elements, preventing incorrect decimal separators under non-invariant cultures.

Changes:

  • Format vector float elements with "R" and CultureInfo.InvariantCulture in SqlServerVectorTypeMapping.GenerateNonNullSqlLiteral.
  • Add a regression test running under de-DE to validate invariant-culture formatting for vector literals.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/EFCore.SqlServer/Storage/Internal/SqlServerVectorTypeMapping.cs Formats float vector elements using invariant culture to avoid culture-dependent decimal separators in generated SQL literals.
test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs Adds a de-DE culture regression test ensuring generated vector SQL literals use . as decimal separator.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants