So, I have a query the same as below:
query = plpy.prepare(
"SELECT count(id) FROM contracts WHERE dependent_id = $1",
params = [dependent_id]
If my field
None, it works well.
But, if I have a
None at this field, query is getting work incorrect.
= isn't the same as
IS when you compare with
I tried to use if-else expression to correct my query string, but when query contains
IS, I catch the syntax exception.
After I'd logged my query with
IS keyword (when my field is
None), I executed it in a PSQL shell, and it had worked well.
IS doesn't work at the
plpythonu stored procedure, but still works at the native SQL query?
I had a discussion with DBA at my work, and he thinks it's bug in
plpythonu with type conversion. Because
plpy.execute rising exception when we trying to use
IS with integer type.
After you've declared field as integer and used
IS in query at prepare step, you will get syntax exception on execute step.
Workaround is query string with obvious indication your
None field as
IS NULL or
IS NOT NULL
P.S. Sorry for my English.