Skip to content

migrations: keep lines longer than 64KB when stripping schema files - #4724

Open
adityajai119 wants to merge 1 commit into
sqlc-dev:mainfrom
adityajai119:fix-migrations-long-lines
Open

adityajai119 wants to merge 1 commit into
sqlc-dev:mainfrom
adityajai119:fix-migrations-long-lines

Conversation

@adityajai119

Copy link
Copy Markdown

RemoveRollbackStatements and RemovePsqlMetaCommands read schema files with a bufio.Scanner using its default 64KB token limit and never check s.Err(). When a schema or migration file contains a line longer than 64KB (for example a large seed INSERT or a pg_dump line with a long literal), Scan stops at that line and both functions return only the content before it. sqlc then silently parses a truncated schema, so tables defined after that line are missing.

The fix sizes the scanner buffer to the input length so any line in the file fits.

Added TestRemoveLongLines in internal/migrations, which fails before the change (output cut at the long line) and passes after. Ran go test ./internal/migrations and go vet ./internal/migrations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant