Skip to content

Commit

Permalink
fix trigger for json/jsonb
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed Sep 27, 2019
1 parent 12dd496 commit bc10e39
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fence/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,15 +704,15 @@ def migrate(driver):
BEGIN
IF (TG_OP = 'DELETE') THEN
INSERT INTO user_audit_logs (timestamp, operation, old_values)
SELECT now(), 'DELETE', row_to_json(OLD);
SELECT now(), 'DELETE', to_jsonb(OLD);
RETURN OLD;
ELSIF (TG_OP = 'UPDATE') THEN
INSERT INTO user_audit_logs (timestamp, operation, old_values, new_values)
SELECT now(), 'UPDATE', row_to_json(OLD), row_to_json(NEW);
SELECT now(), 'UPDATE', to_jsonb(OLD), to_jsonb(NEW);
RETURN NEW;
ELSIF (TG_OP = 'INSERT') THEN
INSERT INTO user_audit_logs (timestamp, operation, new_values)
SELECT now(), 'INSERT', row_to_json(NEW);
SELECT now(), 'INSERT', to_jsonb(NEW);
RETURN NEW;
END IF;
RETURN NULL;
Expand Down

0 comments on commit bc10e39

Please sign in to comment.