Skip to content

AZ625: A cascade line that names no foreign key ​

cascade from schema.table, under rules, says that a foreign key of the rules' table to that table deletes or changes its rows as meant (ON DELETE CASCADE, SET NULL or SET DEFAULT, ON UPDATE SET NULL or SET DEFAULT), so applying doesn't warn of it. Applying refuses the line when it names no such key: there is none to that table, or its action is RESTRICT or NO ACTION (nothing to say). Remove the line, or fix the table's name. When several keys of the table to that table act, the line says which by its columns. Here app.files has two keys to app.users, owner_id and editor_id, both ON DELETE SET NULL.

Reported when the policy is applied (rowstile push, apply, a migration), against the database.

The mistake ​

authz
app role app_user
type user = app.users
type file = app.files
  owner : user = owner_id
  can view = owner
rules app.files
  select : view
  cascade from app.users

Fixed ​

authz
app role app_user
type user = app.users
type file = app.files
  owner : user = owner_id
  can view = owner
rules app.files
  select : view
  cascade from app.users (owner_id)