Fix deparser regex quote truncation in CREATE DOMAIN CHECK constraints #29
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.
Fix deparser regex quote truncation in CREATE DOMAIN CHECK constraints
Problem
The deparser was dropping closing quotes and
$characters from regex patterns in CREATE DOMAIN CHECK constraints, causing the deparser to generate invalid SQL that could not be reparsed.Root Cause
JavaScript's
String.replace()method was interpreting the$character in regex patterns as special replacement syntax. When the BoolExpr method processed AND/OR expressions containing regex patterns ending with$', theString.replace('%s', joinedArgs)call would truncate the final$'characters because JavaScript treated$as a replacement pattern indicator.Technical Details
The issue occurred in the BoolExpr method in
packages/deparser/src/deparser.ts:Before (broken):
After (fixed):
Example Fix
Input SQL:
Before fix (invalid SQL):
After fix (valid SQL):
Testing
misc-launchql-ext-typestestChanges Made
String.replace()String.replace()misc-launchql-ext-types.test.tstestImpact
This fix ensures that regex patterns in CHECK constraints are properly preserved through the deparser pipeline, maintaining the fundamental contract that deparsed SQL should be valid and reparsable.
Link to Devin run: https://app.devin.ai/sessions/53c6e39590e9403ab99a25afe0dd5e99
Requested by: Dan Lynch ([email protected])