Affected area: Migrations
Supabase CLI version: current develop (d38ccd7)
Operating system: Any. Reproduced with a unit test on Linux.
Installation method: Built from source
Command
Actual output
A migration containing this statement fails with a syntax error:
The CLI splits the statement at the semicolon inside the string literal and sends select E'it\'s and here' as two statements.
Expected behavior
The statement is sent as one statement. In an escape string constant, \' is an escaped quote and does not end the literal.
Steps to reproduce
- Add a migration that contains
select E'it\'s; here';.
- Run
supabase db push against a database.
- See the syntax error caused by the split statement.
Additional context
The splitter in apps/cli/src/command-internal/sql-split.ts only treats a doubled quote as an escape inside single-quoted strings. PostgreSQL also accepts backslash escapes in E'...' strings, so the first \' is read as the end of the literal. A unit test for splitAndTrim fails on develop and passes when backslash escapes are honored for escape string constants only. Standard strings such as 'a\' are unchanged. The same splitter is used by seed files and the declarative schema commands.
I have a fix with a unit test ready and can open a PR if this is open for contribution.
Affected area: Migrations
Supabase CLI version: current
develop(d38ccd7)Operating system: Any. Reproduced with a unit test on Linux.
Installation method: Built from source
Command
Actual output
A migration containing this statement fails with a syntax error:
The CLI splits the statement at the semicolon inside the string literal and sends
select E'it\'sandhere'as two statements.Expected behavior
The statement is sent as one statement. In an escape string constant,
\'is an escaped quote and does not end the literal.Steps to reproduce
select E'it\'s; here';.supabase db pushagainst a database.Additional context
The splitter in
apps/cli/src/command-internal/sql-split.tsonly treats a doubled quote as an escape inside single-quoted strings. PostgreSQL also accepts backslash escapes inE'...'strings, so the first\'is read as the end of the literal. A unit test forsplitAndTrimfails ondevelopand passes when backslash escapes are honored for escape string constants only. Standard strings such as'a\'are unchanged. The same splitter is used by seed files and the declarative schema commands.I have a fix with a unit test ready and can open a PR if this is open for contribution.