mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Fix schema mismatch in empty result query
When no permission rules exist, the query was returning 2 columns (parent, child) but the function contract specifies 3 columns (parent, child, reason). This could cause schema mismatches in consuming code. Added 'NULL AS reason' to match the documented 3-column schema. Added regression test that verifies the schema has 3 columns even when no permission rules are returned. The test fails without the fix (showing only 2 columns) and passes with it. Thanks to @asg017 for catching this
This commit is contained in:
parent
79879b834a
commit
b311f735f9
2 changed files with 57 additions and 1 deletions
|
|
@ -116,7 +116,7 @@ async def build_allowed_resources_sql(
|
|||
|
||||
# If no rules, return empty result (deny all)
|
||||
if not rule_sqls:
|
||||
return "SELECT NULL AS parent, NULL AS child WHERE 0", {}
|
||||
return "SELECT NULL AS parent, NULL AS child, NULL AS reason WHERE 0", {}
|
||||
|
||||
# Build the cascading permission query
|
||||
rules_union = " UNION ALL ".join(rule_sqls)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue