Skip to content

Commit

Permalink
chore: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jfagoagas committed Dec 12, 2024
1 parent a0fc4e2 commit a2e5801
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/src/backend/api/rls.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def create_sql(self, model: Any, schema_editor: Any) -> Any:
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 = (
Expand Down

0 comments on commit a2e5801

Please sign in to comment.