Closed satsva closed 3 years ago
If you look at the line just before the KeyError, you'll see the third key to db.functions
is self.arguments or ''
and in the next line self.arguments
is shown as "'true', 'pid', '{NULL}'"
. So it seems the third argument to your audit.if_modified_func
trigger functions is (mis)interpreted as having the value {NULL}
.
Aside from perhaps providing a simple example that exhibits the problem, I would recommend that you examine the arguments of your problem function. First you can issue the query that is in lines 94-113, and pay special attention to the column named arguments
, which comes from encode(tgargs, 'escape') AS arguments
(line 104). Then you can put some debugging print()s
before the if arguments ...
in line 54 and after the assignment to self.arguments in lines 55-56.
Thank you for taking time to review and pointers. After much troubleshooting I was able to resolve the issue. Issue is the User I am using to connect to the database doesn't have search_path set to the schema where I have the trigger procedure i.e., Tables are in schema X and the audit procedure is in Schema Y (not real schema names of course). Once I set the search_path to both schemas everything went well.
However, wondering why it worked if I removed all the arguments?
It worked when you removed all the arguments because if there are no arguments, self.arguments
is set to None
(in Trigger.__init__
) and then in the line that I showed above the third key used to access db.functions
is set to an empty string and that is present in that dict.
This issue is similar to #99. In general, Pyrseas uses queries directly against the catalogs, which are generally visible to any user. However, in some places we use functions like the encode()
mentioned above and those aren't as visible to anyone.
First time user of Pyrseas and I am getting the below KeyError. All my Tables have Triggers which keeps an audit log of data changes. If I remove the arguments for the trigger procedure dbtoyaml works fine. Postgres allows passing arguments to trigger function so why is dbtoyaml failing?
dbtoyaml version 0.9.1