Skip to content

fix: resolve the object type behind modifiers in statement_type - #301

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/sileht/sqlparse-0.6/bump-sqlparse-0-6-0--f5b05d1f
Sep 1, 2026
Merged

fix: resolve the object type behind modifiers in statement_type#301
mergify[bot] merged 1 commit into
mainfrom
devs/sileht/sqlparse-0.6/bump-sqlparse-0-6-0--f5b05d1f

Conversation

@sileht

@sileht sileht commented Aug 27, 2026

Copy link
Copy Markdown
Member

Statement.statement_type took the first two keywords, so any keyword
sitting between the verb and the object displaced the object out of the
window. sqlparse 0.6.0 made that visible by lexing MATERIALIZED as a
keyword, but it predates the bump: TEMPORARY, TEMP and UNIQUE were
already doing it.

CREATE TEMPORARY TABLE "CREATE TEMPORARY" -> "CREATE TABLE"
CREATE TEMP TABLE "CREATE TEMP" -> "CREATE TABLE"
CREATE UNIQUE INDEX "CREATE UNIQUE" -> "CREATE INDEX"
CREATE MATERIALIZED VIEW "CREATE MATERIALIZED"-> "CREATE MATERIALIZED VIEW"
DROP MATERIALIZED VIEW "DROP MATERIALIZED" -> "DROP MATERIALIZED VIEW"
ALTER MATERIALIZED VIEW "ALTER MATERIALIZED" -> "ALTER MATERIALIZED VIEW"
REFRESH MATERIALIZED VIEW "MATERIALIZED" -> "REFRESH MATERIALIZED VIEW"
CREATE OR REPLACE VIEW "CREATE OR REPLACE" -> "CREATE OR REPLACE VIEW"

Three kinds of word are now told apart: modifiers that do not change what
the object is and are dropped (TEMPORARY, TEMP, GLOBAL, LOCAL, UNIQUE,
RECURSIVE); qualifiers that are part of the object's name and let it
continue (MATERIALIZED); and verbs sqlparse does not lex as keywords at
all, recovered from the statement's first token (REFRESH, which came
through with ttype None and left the type headless).

OBJECT_VERBS deliberately holds only verbs that are always followed by
the keyword naming their object. TRUNCATE acts on a name, so pairing it
with the next keyword would read a trailing option as the object type and
invent "TRUNCATE CASCADE", "TRUNCATE RESTART" and friends; it stays out,
and tests pin that.

This fixes one comparison, not just the labels. "CREATE TEMPORARY" was
not in UnorderedTokenList.STATEMENT_TYPES, so temporary tables never
had their column lists sorted and two identical ones written in a
different column order compared as drifted. They now behave like plain
CREATE TABLE. Temporary tables that genuinely differ still compare
unequal, statements with no keywords still resolve to UNKNOWN so
_parse_statements filters exactly what it filtered before, and a
statement behind a leading comment is still typed from its keywords.

Claude-Session: https://claude.ai/code/session_01XkWQRxh5pfi2Fbuv3Z9wen
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com

@sileht

sileht commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 ci(mergify): don't check Python 3.9 tests #299
2 chore: drop Python 3.9 support #300
3 chore(deps): bump sqlparse to 0.6.0 #301 👈

@mergify

mergify Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 6 merge protections satisfied — ready to merge.

Show 6 satisfied protections

🟢 🤖 Continuous Integration

  • all of:
    • check-success=Test with Python 3.10
    • check-success=Test with Python 3.11
    • check-success=Test with Python 3.12
    • check-success=semgrep

🟢 👀 Review Requirements

  • any of:
    • #approved-reviews-by>=1
    • author = dependabot[bot]

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|internal|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?!?:

🟢 🔎 Reviews

  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

  • body ~= (?ms:.{48,})

🟢 🚦 Auto-queue

When all merge protections are satisfied, this pull request will be queued automatically.

@mergify
mergify Bot deployed to Mergify Merge Protections August 27, 2026 15:19 Active
@sileht
sileht marked this pull request as ready for review August 27, 2026 15:19
@mergify
mergify Bot requested a review from a team August 27, 2026 15:26
Base automatically changed from devs/sileht/sqlparse-0.6/drop-python-3-9-support--220426d7 to main August 28, 2026 08:35
@mergify

mergify Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

@sileht this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label Aug 28, 2026
jd
jd previously approved these changes Aug 28, 2026
@sileht
sileht force-pushed the devs/sileht/sqlparse-0.6/bump-sqlparse-0-6-0--f5b05d1f branch from db8670e to 5a9c785 Compare August 28, 2026 14:27
@sileht

sileht commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

Revision history

# Type Changes Reason Date
1 initial db8670e 2026-08-28 14:27 UTC
2 rebase db8670e → 5a9c785 (rebase only) 2026-08-28 14:27 UTC
3 content 5a9c785 → bc14ac6 2026-08-31 07:26 UTC
4 content bc14ac6 → 18e652b 2026-08-31 07:38 UTC
5 content 18e652b → 0f64cce 2026-08-31 08:30 UTC
6 content 0f64cce → 83fb20f (raw) 2026-08-31 08:52 UTC
7 content 83fb20f → 35642ab (raw) 2026-08-31 15:41 UTC

@mergify
mergify Bot dismissed jd’s stale review August 28, 2026 14:28

Pull request has been modified.

@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 28, 2026 14:28 Failure
@mergify
mergify Bot requested a review from a team August 28, 2026 14:29
@mergify mergify Bot removed the conflict label Aug 28, 2026
@sileht
sileht force-pushed the devs/sileht/sqlparse-0.6/bump-sqlparse-0-6-0--f5b05d1f branch from 5a9c785 to bc14ac6 Compare August 31, 2026 07:26
Copilot AI lite review requested due to automatic review settings August 31, 2026 07:26
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 31, 2026 07:26 Failure

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The dependency bump is well-scoped and the tests are updated to explicitly pin the relevant externally visible behavior changes.

Pull request overview

This PR upgrades the project’s sqlparse dependency to 0.6.0 to pick up security/DoS fixes, and updates tests to pin the observable Statement.statement_type behavior changes introduced by the new lexer keywording.

Changes:

  • Bump sqlparse minimum version to >=0.6.0 and update the lockfile to 0.6.0.
  • Extend test_statement_type coverage to pin MATERIALIZED/TEMPORARY statement-type outcomes under the updated lexer behavior.
File summaries
File Description
tests/test_sql_compare.py Adds/updates statement type expectations for MATERIALIZED VIEW and TEMPORARY TABLE cases under sqlparse 0.6.0.
pyproject.toml Raises the minimum supported sqlparse version to >=0.6.0.
poetry.lock Locks sqlparse to 0.6.0 and updates associated metadata/hashes.
Review details
  • Files reviewed: 2/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_sql_compare.py Outdated
@sileht
sileht force-pushed the devs/sileht/sqlparse-0.6/bump-sqlparse-0-6-0--f5b05d1f branch from bc14ac6 to 18e652b Compare August 31, 2026 07:38
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 31, 2026 07:38 Failure
@sileht
sileht force-pushed the devs/sileht/sqlparse-0.6/bump-sqlparse-0-6-0--f5b05d1f branch from 18e652b to 0f64cce Compare August 31, 2026 08:30
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 31, 2026 08:31 Failure
@mergify

mergify Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@sileht this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label Aug 31, 2026
@sileht sileht changed the title chore(deps): bump sqlparse to 0.6.0 test: pin statement_type values changed by sqlparse 0.6.0 Aug 31, 2026
@sileht
sileht force-pushed the devs/sileht/sqlparse-0.6/bump-sqlparse-0-6-0--f5b05d1f branch from 0f64cce to 83fb20f Compare August 31, 2026 08:52
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections August 31, 2026 08:52 Failure
@mergify mergify Bot removed the conflict label Aug 31, 2026
Comment thread tests/test_sql_compare.py Outdated
Comment thread tests/test_sql_compare.py Outdated
Comment thread tests/test_sql_compare.py Outdated
`Statement.statement_type` took the first two keywords, so any keyword
sitting between the verb and the object displaced the object out of the
window. sqlparse 0.6.0 made that visible by lexing MATERIALIZED as a
keyword, but it predates the bump: TEMPORARY, TEMP and UNIQUE were
already doing it.

  CREATE TEMPORARY TABLE      "CREATE TEMPORARY"   -> "CREATE TABLE"
  CREATE TEMP TABLE           "CREATE TEMP"        -> "CREATE TABLE"
  CREATE UNIQUE INDEX         "CREATE UNIQUE"      -> "CREATE INDEX"
  CREATE MATERIALIZED VIEW    "CREATE MATERIALIZED"-> "CREATE MATERIALIZED VIEW"
  DROP MATERIALIZED VIEW      "DROP MATERIALIZED"  -> "DROP MATERIALIZED VIEW"
  ALTER MATERIALIZED VIEW     "ALTER MATERIALIZED" -> "ALTER MATERIALIZED VIEW"
  REFRESH MATERIALIZED VIEW   "MATERIALIZED"       -> "REFRESH MATERIALIZED VIEW"
  CREATE OR REPLACE VIEW      "CREATE OR REPLACE"  -> "CREATE OR REPLACE VIEW"

Three kinds of word are now told apart: modifiers that do not change what
the object is and are dropped (TEMPORARY, TEMP, GLOBAL, LOCAL, UNIQUE,
RECURSIVE); qualifiers that are part of the object's name and let it
continue (MATERIALIZED); and verbs sqlparse does not lex as keywords at
all, recovered from the statement's first token (REFRESH, which came
through with ttype None and left the type headless).

`OBJECT_VERBS` deliberately holds only verbs that are always followed by
the keyword naming their object. TRUNCATE acts on a name, so pairing it
with the next keyword would read a trailing option as the object type and
invent "TRUNCATE CASCADE", "TRUNCATE RESTART" and friends; it stays out,
and tests pin that.

This fixes one comparison, not just the labels. "CREATE TEMPORARY" was
not in `UnorderedTokenList.STATEMENT_TYPES`, so temporary tables never
had their column lists sorted and two identical ones written in a
different column order compared as drifted. They now behave like plain
CREATE TABLE. Temporary tables that genuinely differ still compare
unequal, statements with no keywords still resolve to UNKNOWN so
`_parse_statements` filters exactly what it filtered before, and a
statement behind a leading comment is still typed from its keywords.

Claude-Session: https://claude.ai/code/session_01XkWQRxh5pfi2Fbuv3Z9wen
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Change-Id: If5b05d1f96310d93905b8f759e12d84f6f1d363f
@sileht sileht changed the title test: pin statement_type values changed by sqlparse 0.6.0 fix: resolve the object type behind modifiers in statement_type Aug 31, 2026
@sileht
sileht force-pushed the devs/sileht/sqlparse-0.6/bump-sqlparse-0-6-0--f5b05d1f branch from 83fb20f to 35642ab Compare August 31, 2026 15:41
@mergify
mergify Bot deployed to Mergify Merge Protections August 31, 2026 15:43 Active
@mergify

mergify Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-09-01 09:07 UTC · Rule: default · triggered by merge protections
  • Checks skipped · PR is already up-to-date
  • Merged2026-09-01 09:08 UTC · at 35642ab80ab45c616329dce14d88b2fa29069c62 · squash

This pull request spent 47 seconds in the queue, including 9 seconds running CI.

Required conditions to merge

@mergify
mergify Bot merged commit 67ab960 into main Sep 1, 2026
10 checks passed
@mergify
mergify Bot deleted the devs/sileht/sqlparse-0.6/bump-sqlparse-0-6-0--f5b05d1f branch September 1, 2026 09:08
@mergify mergify Bot added queued and removed queued labels Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants