mirror of
https://github.com/simonw/datasette.git
synced 2026-07-17 04:54:43 +02:00
Compare commits
1 commit
main
...
claude/opt
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e57ae03e22 |
2 changed files with 11 additions and 1 deletions
|
|
@ -405,8 +405,13 @@ async def _build_single_action_sql(
|
|||
|
||||
# Add restriction filter if there are restrictions
|
||||
if restriction_sqls:
|
||||
# Short-circuit optimization: if restriction_list is empty (e.g., due to
|
||||
# INTERSECT of conflicting restrictions), the uncorrelated EXISTS check
|
||||
# returns false once, avoiding per-row evaluation of the correlated subquery.
|
||||
# See: https://emschwartz.me/short-circuiting-correlated-subqueries-in-sqlite/
|
||||
query_parts.append(
|
||||
"""
|
||||
AND EXISTS (SELECT 1 FROM restriction_list)
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM restriction_list r
|
||||
WHERE (r.parent = decisions.parent OR r.parent IS NULL)
|
||||
|
|
|
|||
|
|
@ -324,7 +324,12 @@ async def resolve_permissions_from_catalog(
|
|||
filtered AS (
|
||||
SELECT p.parent, p.child
|
||||
FROM permitted p
|
||||
WHERE EXISTS (
|
||||
-- Short-circuit optimization: if restriction_list is empty (e.g., due to
|
||||
-- INTERSECT of conflicting restrictions), the uncorrelated EXISTS check
|
||||
-- returns false once, avoiding per-row evaluation of the correlated subquery.
|
||||
-- See: https://emschwartz.me/short-circuiting-correlated-subqueries-in-sqlite/
|
||||
WHERE EXISTS (SELECT 1 FROM restriction_list)
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM restriction_list r
|
||||
WHERE (r.parent = p.parent OR r.parent IS NULL)
|
||||
AND (r.child = p.child OR r.child IS NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue