fix(drizzle-kit): preserve MySQL enum values containing commas#5965
Open
sanjibani wants to merge 2 commits into
Open
fix(drizzle-kit): preserve MySQL enum values containing commas#5965sanjibani wants to merge 2 commits into
sanjibani wants to merge 2 commits into
Conversation
…ulation race The cache invalidation in PgPreparedQuery.queryWithCache was firing concurrently with the DB write via Promise.all, contradicting the in-code comment that said the DB write should resolve first. When onMutate (a single Redis Lua script call) completed before the DB write committed, a concurrent SELECT could read the pre-mutation row and repopulate the cache via cache.put(), serving stale data until TTL expiry. Repro: write-heavy workload with cache ex > DB RTT. Change Promise.all([query(), onMutate]) to sequential await. The DB write now commits before any cache keys are cleared, closing the race. Same fix applied to mysql-core, sqlite-core, gel-core, singlestore-core which shared the identical pattern. Regression test added in pg-common-cache.ts that fails on the old ordering (query:end > onMutate) and passes on the new (query:end < onMutate). Closes drizzle-team#5828
The MySQL serializer's handleEnumType helper reparses the generated
enum('a,b','c') SQL string by splitting on raw commas. That collapses
'a,b' into two pieces 'a' and 'b', corrupting the snapshot type to
enum('','','c') when an enum value contains a comma.
Parse the value list as quoted SQL string literals instead. The new
matchAll pattern matches 'value' segments and tolerates escaped '' for
embedded single quotes (consistent with the existing
escapeSingleQuotes round-trip).
Closes drizzle-team#5957.
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.
The MySQL serializer's handleEnumType helper reparses the generated enum('a,b','c') SQL string by splitting on raw commas. When an enum value contains a comma (e.g. mysqlEnum('e', ['a,b', 'c'])), the splitter collapses 'a,b' into two pieces 'a' and 'b', corrupting the snapshot type to enum('','','c').
The new matchAll pattern parses the value list as quoted SQL string literals. It tolerates escaped '' for embedded single quotes (consistent with the existing escapeSingleQuotes round-trip).
Regression test added in drizzle-kit/tests/mysql.test.ts: add table with enum value containing comma. The test asserts that mysqlEnum('enum', ['a,b', 'c']) generates type "enum('a,b','c')" in the snapshot. The test fails on the previous raw comma split (would produce enum('','','c')) and passes on the new quoted-string parsing.
Closes #5957.