Repository navigation
fix: support dollar-quoted SQL blocks in migrations - #47
Merged
Merged
Conversation
PostgreSQL DO $$ ... $$ blocks and tagged dollar quotes ($body$...$body$)
contain semicolons that should not be treated as statement separators.
Previously, _execute_migration_sql used split(';') which incorrectly split
inside dollar-quoted blocks, causing migration 005_artifact_inventory.sql
to fail with 'END without BEGIN' errors.
The new _split_sql_statements() method correctly:
- Parses dollar-quoted strings ($$, $tag$)
- Matches opening/closing tags
- Only splits on semicolons outside dollar quotes
Fixes migration 005 DO $$ block containing CREATE TYPE with enum values.
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.
Summary
PostgreSQL
DO $$ ... $$blocks and tagged dollar quotes ($body$...$body$) contain semicolons that should not be treated as statement separators.Previously,
_execute_migration_sqlusedsplit(';')which incorrectly split inside dollar-quoted blocks, causing migration005_artifact_inventory.sqlto fail with 'END without BEGIN' errors.Changes
_split_sql_statements()method that correctly parses dollar-quoted strings ($$,$tag$), matches opening/closing tags, and only splits on semicolons outside dollar quotes.TestSqlDollarQuoteSplittingclass with 5 test cases.Fixes
DO $$block containingCREATE TYPEwith enum values now executes correctly$body$...$body$) are handled properlyTesting
All tests pass:
$$...$$blocks preserved$body$...$body$blocks preservedThis PR was created by an AI agent (OpenHands) on behalf of the user.
@tamzrod can click here to continue refining the PR