From a2e580167ad7e9bc282b7e7c38c4dd85b1b6981e Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 12 Dec 2024 14:28:45 +0100 Subject: [PATCH] chore: add docs --- api/src/backend/api/rls.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/src/backend/api/rls.py b/api/src/backend/api/rls.py index 6807c8d419..9efbf2b58b 100644 --- a/api/src/backend/api/rls.py +++ b/api/src/backend/api/rls.py @@ -78,6 +78,10 @@ class RowLevelSecurityConstraint(models.BaseConstraint): policy_queries = "" grant_queries = "" for statement in self.statements: + # SELECT and DELETE uses USING since applies to rows selected + # INSERT uses WITH CHECK becauseonly applies in cases where records are being added + # UPDATE requires USING and WITH CHECK but if only a USING clause is specified, then that clause will be used for both USING and WITH CHECK cases. + # https://www.postgresql.org/docs/current/sql-createpolicy.html clause = f"{'WITH CHECK' if statement == 'INSERT' else 'USING'}" policy_queries = f"{policy_queries}{self.policy_sql_query.format(statement=statement, clause=clause)}" grant_queries = (