From a5910f200e10ef5d1de314a6679f9a25a61c0910 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 25 Oct 2025 09:50:21 -0700 Subject: [PATCH] Code cleanup: rename variables, remove WHERE 0 check, cleanup files, refs #2528 - Rename permission_name to action_name in debug templates for consistency - Remove confusing WHERE 0 check from check_permission_for_resource() - Rename tests/test_special.py to tests/test_search_tables.py - Remove tests/vec.db that shouldn't have been committed --- datasette/templates/debug_check.html | 4 ++-- datasette/templates/debug_rules.html | 4 ++-- datasette/utils/actions_sql.py | 2 +- .../{test_special.py => test_search_tables.py} | 0 tests/vec.db | Bin 49152 -> 0 bytes 5 files changed, 5 insertions(+), 5 deletions(-) rename tests/{test_special.py => test_search_tables.py} (100%) delete mode 100644 tests/vec.db diff --git a/datasette/templates/debug_check.html b/datasette/templates/debug_check.html index 250408dd..47fce5cb 100644 --- a/datasette/templates/debug_check.html +++ b/datasette/templates/debug_check.html @@ -110,8 +110,8 @@ The permission action to check diff --git a/datasette/templates/debug_rules.html b/datasette/templates/debug_rules.html index c29f37de..3873bebe 100644 --- a/datasette/templates/debug_rules.html +++ b/datasette/templates/debug_rules.html @@ -26,8 +26,8 @@ The permission action to check diff --git a/datasette/utils/actions_sql.py b/datasette/utils/actions_sql.py index 79642720..dfd0867f 100644 --- a/datasette/utils/actions_sql.py +++ b/datasette/utils/actions_sql.py @@ -486,7 +486,7 @@ async def check_permission_for_resource( rules_union, all_params = await build_permission_rules_sql(datasette, actor, action) # If no rules (empty SQL), default deny - if not rules_union or rules_union.endswith("WHERE 0"): + if not rules_union: return False # Add parameters for the resource we're checking diff --git a/tests/test_special.py b/tests/test_search_tables.py similarity index 100% rename from tests/test_special.py rename to tests/test_search_tables.py diff --git a/tests/vec.db b/tests/vec.db deleted file mode 100644 index 195ef213d3a49a5441fec3a92c6f5cd551e2d851..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49152 zcmeI)-)_=S9Ki9G{~(OrOfGhFvUvenV}?9{W7rrXV-t&UA%x&4+Q`6-GXGqSy@*%F zckoJI!6)!`51?j=F&-$G!ra1*7vT4#hqkAO)8FsYa?#NC(Zhmeo1)n{KCIg!qbw_` zs%#0ND2iX!sI21>kPE)?ikz#i<*OF`%I)TPEcRUqMn5R=k4rz6-p78$0efgPN>%=eX-y%$4-4p^L})l2OhUgpu7Y z=)$#K^tx92*`Q@J`LbiRZP9FX>UJelP4#d3gNa;D?PsRPAMK}h@VwW4(cRp1jW@k1 zFbcrg@!B;#*OJGbS5`ypmGV2;(!O}0?`yLAARn<^*xeSzT|*Shg+i(v2qdhWs#xuY z`MP`5lGkdrde4^8%k@D3V~6QrYUyh>1|@N5z}&y(3ntQOwcovz_b@^?Z_R1(U!A4X zVVqpPXz2I#k~>L}EgQS}q8wpIFB+QF(1xrvNipg@YUnhZUDF;nruMvn#KwlYKMZoD z&^3>GX8XXLTJ=qYH?=X@t{9CfZ&gPoj zyVhHCoZp|rt)0|cR>QL2Or8ar13TH6x~B#btE*~#oWSVUFqnBJLamHWt*S^ygbpFG zUzGT{{GcF!00IagfB*srAbv}@dfAUffaSC*?DNex&Qw{iC@e~ zdW4Ap0tg_000IagfB*srAb4OHQ&<7E~Y-k%_7CpNgC)2q1s}0tg_000IagfB*srAh3V} zUT-)o(;8F?0tg_000IagfB*srAb63IYfqfB*srAb