I have a hstore field in an audit table that stores all the fields that have changed as a result of an operation.
On inserts, the key,
changed_fields is NULL and on system updates it is set to
system. I would like to return all rows where either the key is not defined or the key is not
system but I am lost as to how to do this.
So far I have tried
select changed_fields -> 'updated_by' from audit.logged_actions where (changed_fields -> 'updated_by' != 'system' or defined(changed_fields, 'updated_by') = false) order by event_id desc
But that doesn't work and I am not quite sure why. Any ideas on what I am doing wrong?