Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Feb 28, 2025

Fixes #3476

@roji roji requested a review from Copilot February 28, 2025 15:24
@roji roji enabled auto-merge (squash) February 28, 2025 15:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR aims to preserve the collation when changing a column’s type.

  • Updates the logic to always add an explicit COLLATE clause when a new collation is provided.
  • Enhances the SQL generation to reset collation to a default when the type remains unchanged.

Reviewed Changes

File Description
src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs Adjusts COLLATE clause logic during ALTER COLUMN operations.
test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs Updates tests to validate the new collation preservation behavior.

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs:981

  • The test currently verifies the non-default collation scenario; however, ensure there is corresponding coverage for the branch in which newCollation is null and the default collation is explicitly reset.
AssertSql(...

@roji roji merged commit a6b55b5 into npgsql:main Feb 28, 2025
15 checks passed
@roji roji deleted the AlterColumnCollation branch February 28, 2025 15:35
roji added a commit that referenced this pull request Feb 28, 2025
roji added a commit that referenced this pull request Feb 28, 2025
roji added a commit that referenced this pull request Feb 28, 2025
roji added a commit that referenced this pull request Feb 28, 2025
@roji
Copy link
Member Author

roji commented Feb 28, 2025

Backported to 9.0.4 via 4bf3248
Backported to 8.0.12 via 9c747fd

roji added a commit that referenced this pull request Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collation lost when changing type from varchar to text

1 participant