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 = (