Repository navigation
fix(analyser): add a semicolon before the COMMIT of banUncommittedTransaction when the last statement has none - #1062
Merged
Merged
Conversation
Base automatically changed from
fix/fix-guard-reparses-edits-outside-statement
to
main
November 1, 2026 12:05
…nsaction when the last statement has none
psteinroe
force-pushed
the
fix/commit-fix-adds-semicolon
branch
from
November 1, 2026 12:05
e76fc09 to
c885787
Compare
edjubert
approved these changes
Nov 2, 2026
…it-fix-adds-semicolon
… gets the COMMIT fix
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.
Stacked on #1044.
#1044 drops
banUncommittedTransaction's fix when the file's last statement has no semicolon, since adding\ncommit;after it doesn't parse. The fix can add the semicolon instead:While writing the spec I found that the fix put the
COMMITinto the body of a SQL function when the file ends with aCREATE FUNCTION: the analyser took the end of the last statement from the last entry of its statement list, which is the last statement of the function's body. The fix guard didn't catch it, since the function still parses withcommit;in its body.What changed
AnalysedFileContext::append_statement(sql)replacesend_offset: it returns where to insert what to add a statement after the last one, with a;first if the last statement has none. Without the text of the last statement, it assumes a semicolon, and fix(analyser): check fixes that edit after their statement on the file #1044's guard still checks the fix on the file.Tests
banUncommittedTransaction/no_semicolon_at_the_end.sqlnow has the fix...;\ncommit;(the harness checks that it parses).banUncommittedTransaction/function_at_the_end.sql: theCOMMITgoes after theCREATE FUNCTION. Without the change, it goes into the function body.cargo test -p pgls_analyser,cargo clippy --workspace --all-targets -- -D warnings.