Skip to content

Keep GRANT and REVOKE privilege clauses together when reindenting - #921

Open
adenzhou1350 wants to merge 1 commit into
andialbrecht:masterfrom
adenzhou1350:codex/fix-dcl-reindent
Open

adenzhou1350 wants to merge 1 commit into
andialbrecht:masterfrom
adenzhou1350:codex/fix-dcl-reindent

Conversation

@adenzhou1350

Copy link
Copy Markdown

reindent=True treats permission names such as SELECT as new statements and REVOKE's FROM as a query clause:

REVOKE
SELECT ON TABLE customers
FROM umbrella;

Keep those boundaries together when the statement starts with a DCL keyword. Nested groups still use the existing formatter, and subsequent SELECT statements retain normal indentation. Token classification is unchanged: GRANT/REVOKE remain DCL and SELECT remains DML.

Fixes #409. This is separate from the keyword-classification change discussed in #719.

Validation on native Windows Python 3.14.3:

  • The same 12 regression/control cases: 10 fail and 2 pass on unchanged master; all pass with this change.
  • Full suite: 518 passed, 2 xfailed, 1 xpassed (existing xfail/xpass outcomes unchanged).
  • Ruff and git diff --check pass.

Tests cover permission lists, REVOKE GRANT OPTION FOR, leading comments, keyword casing, repeat formatting, a following query, and unchanged lexical token types. This is a formatting test, not a live database authorization test.

  • ran the tests (pytest)
  • all style issues addressed (ruff)
  • changes covered by tests
  • changelog updated; no public API changes

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.

GRANT SELECT ON schema.object TO role; miscategorizes SELECT as the start of a statement for reindent=True

1 participant