Skip to content

Add configurable grouping token limit - #892

Open
RamiNoodle733 wants to merge 1 commit into
andialbrecht:masterfrom
RamiNoodle733:feature/configurable-grouping-token-limit-841
Open

Add configurable grouping token limit#892
RamiNoodle733 wants to merge 1 commit into
andialbrecht:masterfrom
RamiNoodle733:feature/configurable-grouping-token-limit-841

Conversation

@RamiNoodle733

Copy link
Copy Markdown

Adds a public sqlparse.set_max_grouping_tokens() helper so callers can adjust the existing grouping token-count DoS guard at runtime for trusted or offline workloads.

The default remains unchanged at 10,000 tokens. Passing None disables the token-count guard, with a docstring warning against doing so for untrusted SQL. Non-positive limits are rejected.

Tests cover:

  • updating and restoring the configured token limit
  • disabling it with None
  • rejecting non-positive limits
  • verifying the configured value changes parser guard behavior

Fixes #841

Checks

  • pytest - not run locally because this execution runtime could not resolve github.com, so the repository could not be cloned into the local execution environment.
  • ruff - not run for the same environment limitation.
  • changes are covered by targeted tests
  • public behavior is documented in the new API docstring

AI-assisted disclosure: This change was prepared with AI assistance. The issue scope, existing DoS guard, public API design, and test cases were reviewed against the repository source and contribution guidance. Local execution was not possible because the runtime could not resolve GitHub; CI should provide execution validation.

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.

Make MAX_GROUPING_TOKENS can be set outside of grouping.py

1 participant