Skip to content

feat: inline enum filters that match a partial index predicate (0.20.0) - #15

Merged
HosseinNejatiJavaremi merged 1 commit into
SyntaxArc:mainfrom
negatic:feat/reviewer-partial-index-bound-params
Oct 14, 2026
Merged

HosseinNejatiJavaremi merged 1 commit into
SyntaxArc:mainfrom
negatic:feat/reviewer-partial-index-bound-params

Conversation

@negatic

@negatic negatic commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

asyncpg runs every query as a server-side prepared statement, and after a few executions Postgres may switch it to a generic plan. A generic plan cannot prove a partial index's WHERE predicate from a bound parameter, so a filter like status IN ($1) stops using ... WHERE status = 'PENDING' indexes and falls back to a broader index or a full scan, with no error and usually no sign of it on a small development database.

Add the pattern to using-archipy-adapters.mdc: render closed-enum values that match a partial index predicate with literal(..., literal_execute=True), keep index-key columns and user input bound, and confirm with a forced generic plan. The archipy-reviewer flags bound filters on predicate columns as Should fix and does not flag the inlined enum literals as unparameterized SQL.

Summary

Checklist

  • python3 scripts/check_catalog.py passes
  • python3 -m unittest discover -s tests -v passes
  • CHANGELOG.md updated for user-facing changes
  • All four JSON manifests share the same version (when releasing)
  • Dual-IDE parity considered (Cursor + Claude Code)

Test plan

asyncpg runs every query as a server-side prepared statement, and after a
few executions Postgres may switch it to a generic plan. A generic plan
cannot prove a partial index's WHERE predicate from a bound parameter, so a
filter like `status IN ($1)` stops using `... WHERE status = 'PENDING'`
indexes and falls back to a broader index or a full scan, with no error and
usually no sign of it on a small development database.

Add the pattern to using-archipy-adapters.mdc: render closed-enum values
that match a partial index predicate with `literal(..., literal_execute=True)`,
keep index-key columns and user input bound, and confirm with a forced
generic plan. The archipy-reviewer flags bound filters on predicate columns
as Should fix and does not flag the inlined enum literals as unparameterized
SQL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HosseinNejatiJavaremi
HosseinNejatiJavaremi merged commit 95e3815 into SyntaxArc:main Oct 14, 2026
3 checks passed
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.

2 participants