{{ message }}
Keep Oracle procedure declarations in split statement#858
Open
gaoflow wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts the statement-splitting logic so sqlparse.split() keeps Oracle CREATE PROCEDURE ... AS/IS declaration sections together with their BEGIN ... END bodies, while avoiding misclassification of PostgreSQL dollar-quoted function bodies after AS as declaration blocks (which could otherwise interfere with splitting subsequent statements).
Changes:
- Track
CREATE {FUNCTION|PROCEDURE|PACKAGE|TRIGGER}blocks and detectAS/ISas a “body follows” marker. - Treat the first non-whitespace/comment token after
AS/ISas either:- a literal body (e.g., dollar-quoted), or
- the start of an implicit Oracle-style declaration section (modeled as a
DECLAREblock) untilBEGIN.
- Add regression tests for Oracle procedure declarations (issue #692) and PostgreSQL dollar-quoted function bodies followed by another statement.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
CREATE PROCEDURE ... ASdeclaration sections in the same split statement as theirBEGIN ... ENDbodyASas declaration sectionsCloses #692
Tests
uv run --group dev --python 3.11 pytest tests/test_split.py::test_split_oracle_procedure_with_declarations tests/test_split.py::test_split_function_with_dollar_quoted_body_and_following_statement -quv run --group dev --python 3.11 pytest tests/test_split.py -quv run --group dev --python 3.11 pytest tests/ -quv run --group dev ruff check sqlparse/ tests/test_split.pygit diff --check