Skip to content

test: scope the carried-policy lookup to the test's own table - #836

Merged
0x054 merged 1 commit into
mainfrom
fix/policy-lookup-scoped-to-table
Oct 30, 2026
Merged

0x054 merged 1 commit into
mainfrom
fix/policy-lookup-scoped-to-table

Conversation

@0x054

@0x054 0x054 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

tests/test_generate_generated_columns.py::test_drift_says_nothing_of_a_policy_carried_around_a_replace[postgres] failed on both Postgres shards of PR #832's CI with ValueError: too many values to unpack (expected 1, got 2) at the [(using,)] = policies line.

Why: the retyped_by_hand helper reads pg_policy by policy name with no table filter. Every Postgres test runs in its own schema, so under xdist two tests can hold a transaction table carrying rls_transaction_direction at the same moment, and the lookup returns both. The pg_attrdef query right above it was already scoped through '"transaction"'::regclass; main's run on cf1ee43 passed on timing alone.

Fix: WHERE polrelid = '"transaction"'::regclass AND polname = ..., the same scoping the neighbouring query uses. No other unscoped pg_policy read exists in tests/.

Verify: uv run --no-sync pytest tests/test_generate_generated_columns.py -k "carried or retyped or policy" --db-backends=postgres -q → 5 passed on Postgres 18.

🤖 Generated with Claude Code

`retyped_by_hand` read `pg_policy` by policy name alone. Every Postgres test
runs in its own schema, and under xdist two tests can hold a `transaction`
table with `rls_transaction_direction` at the same moment, so the lookup saw
two rows and `[(using,)] = policies` failed with "too many values to unpack".
The attrdef query beside it was already scoped through `regclass`; the policy
query now is too. Seen on PR #832's Postgres shards; main's run had passed on
timing alone.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@0x054
0x054 merged commit fa47257 into main Oct 30, 2026
27 of 33 checks passed
@0x054
0x054 deleted the fix/policy-lookup-scoped-to-table branch October 30, 2026 19:17
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.

1 participant