0.1.3: a literal DEFAULT before CHECK, and datetime modifiers, survive schema conversion - #1
Merged
Merged
Conversation
…e schema conversion
rewriteDefault/stripDefault measured the start of the DEFAULT value on the code
mask, where a string literal is blanked to spaces, so `default 'viewer' check
(...)` skipped past 'viewer' and rewrote CHECK as the default value: the
converted DDL read `default 'viewer' (CHECK) (role in (...))` and failed to
parse. Any app that runs its CREATE TABLE statements at start-up through the
client hit this (moshcoding). The gap after DEFAULT is now measured on the
text.
`default (datetime('now','+7 days'))` was short-circuited to now(), dropping
the modifier; only the bare datetime('now') form is special-cased now, and
the function rewriter produces (now() + interval '7 days') for the rest.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Two schema-converter bugs met while porting moshcoding.com's runtime DDL:
role text not null default 'viewer' check (role in (...))converted todefault 'viewer' (CHECK) (role in (...)), which Postgres rejects.rewriteDefault/stripDefaultmeasured the start of the DEFAULT value on the code mask, where the blanked string literal reads as whitespace, so\sdefault\s+swallowed'viewer'and tookCHECKas the value. The gap after DEFAULT is now measured on the text.default (datetime('now','+7 days'))becamenow(), dropping the modifier. Only the baredatetime('now')is special-cased now; the function rewriter turns the rest into(now() + interval '7 days').Unit test added for both; 126/126 pass.
🤖 Generated with Claude Code