Repository navigation
Keep SQL deep scan on for custom read-only allowed_types - #76688
Merged
kaxil merged 2 commits intoNov 8, 2026
Merged
Conversation
validate_sql() skipped the data-modifying deep scan whenever allowed_types was not exactly DEFAULT_ALLOWED_TYPES. A narrower or reordered read-only list such as (exp.Select,) therefore let statements like "WITH d AS (DELETE ...) SELECT ..." or "SELECT ... INTO ..." through. Skip the deep scan only when the allow-list itself admits a data-modifying type.
ColtenOuO
requested review from
Lee-W,
ashb,
gopidesupavan and
kaxil
as code owners
November 7, 2026 16:26
kaxil
reviewed
Nov 8, 2026
An allow-list such as (exp.Select, exp.DML) admits an INSERT at the type check, but the one-way issubclass test left the deep scan on and rejected the same INSERT as read-only. Treat an allowed type that is a write node or a base of one as admitting writes. Scanning only the write types the list does not admit is not an option: MERGE nests Insert and Update, and ALTER ... DROP COLUMN nests Drop, so it would reject writes the list allows. Also update the denylist comment and stability.rst to the new rule.
kaxil
approved these changes
Nov 8, 2026
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.
validate_sql()skipped the data-modifying deep scan wheneverallowed_typeswas not exactlyDEFAULT_ALLOWED_TYPES. So a stricter list like(exp.Select,), a reordered default, or the default plusexp.Describelet these through:Now the deep scan is skipped only when the allow-list itself contains a data-modifying type (e.g.
exp.Insert). Added tests cover the narrower, reordered and widened read-only lists.Was generative AI tooling used to co-author this PR?