Repository navigation
Conversation
Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Refs the issue "Migrations fail when an enum value contains a single quote (Postgres, CockroachDB, MySQL)".
Summary
Enum values were wrapped in single quotes without escaping when rendering
CREATE TYPE ... AS ENUM,ALTER TYPE ... ADD VALUE/DROP VALUE(Postgres and CockroachDB) and MySQLENUM(...)column types, so a value such as@map("it's fine")produced invalid SQL. These places now go through the existingescape_string_literalhelpers, the same as default values already do.Testing performed
New test
enum_values_with_single_quotes_can_be_created_added_and_removedinsql-migration-tests/tests/migrations/enums.rs. It creates an enum with a quoted value, adds another quoted value, removes a value (which recreates the enum on Postgres), and checks that the final push is a no-op.cargo test -p sql-migration-testson PostgreSQL 16 and MySQL 8: all passing, apart from the 7postgres::extensionstests that need the extension image fromdocker/postgres-extand fail the same way without this change.Fixes #5869