Skip to content

Commit 490f311

Browse files
committed
fix: load safeupdate but disable for all but Data API
1 parent 550d9fd commit 490f311

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- migrate:up
2+
ALTER ROLE authenticated SET session_preload_libraries = 'safeupdate';
3+
load 'safeupdate';
4+
5+
SET safeupdate.enabled=0;
6+
7+
-- migrate:down
8+

nix/tests/expected/pg-safeupdate.out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ create table v.foo(
88
update v.foo
99
set val = 'bar';
1010
ERROR: UPDATE requires a WHERE clause
11+
grant all on schema v to authenticated;
12+
set role authenticated;
13+
delete from v.foo;
14+
ERROR: DELETE requires a WHERE clause
15+
reset role;
1116
drop schema v cascade;
1217
NOTICE: drop cascades to table v.foo

nix/tests/expected/roles.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ order by rolname;
6262
rolname | rolconfig
6363
----------------------------+---------------------------------------------------------------------------------
6464
anon | {statement_timeout=3s}
65-
authenticated | {statement_timeout=8s}
65+
authenticated | {statement_timeout=8s,session_preload_libraries=safeupdate}
6666
authenticator | {session_preload_libraries=safeupdate,statement_timeout=8s,lock_timeout=8s}
6767
dashboard_user |
6868
pg_checkpoint |

nix/tests/sql/pg-safeupdate.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ create table v.foo(
1212
update v.foo
1313
set val = 'bar';
1414

15+
grant all on schema v to authenticated;
16+
set role authenticated;
17+
18+
delete from v.foo;
19+
reset role;
1520
drop schema v cascade;
21+
22+
23+

0 commit comments

Comments
 (0)