Skip to content

Commit

Permalink
Update docs for pg-safeupdate (#23177)
Browse files Browse the repository at this point in the history
update safeupdate docs to link to postgrest and fix examples for role/database enabling
  • Loading branch information
encima committed Apr 28, 2024
1 parent d7f6fc6 commit 65efaf3
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -10,11 +10,12 @@ The `pg-safeupdate` extension is a useful tool for protecting data integrity and

## Enable the extension

`pg-safeupdate` can be enabled on a per connection basis:
`pg-safeupdate` can be enabled on a role basis (where `anon` is the role we want to modify in this example):

{/* prettier-ignore */}
```sql
load 'safeupdate';
GRANT SET ON PARAMETER session_preload_libraries TO anon;
ALTER ROLE anon SET session_preload_libraries = 'safeupdate';
```

or for all connections:
Expand All @@ -30,8 +31,6 @@ Let's take a look at an example to see how pg-safeupdate works. Suppose we have

{/* prettier-ignore */}
```sql
load 'safeupdate';

update employees set date_of_birth = '1987-01-28';
```

Expand All @@ -52,3 +51,4 @@ update employees set date_of_birth = '1987-01-28' where id = 12345;
## Resources

- Official [pg-safeupdate documentation](https://github.com/eradman/pg-safeupdate)
- Using [pg-safeupdate with PostgREST](https://postgrest.org/en/v12/integrations/pg-safeupdate.html)

0 comments on commit 65efaf3

Please sign in to comment.