pg-history-viewer
pg-history-viewer copied to clipboard
The "Feature ID" history filter does not work when the PK is not called "id"
Steps
- have a postgis table with a PK that is not
id
- activate audit on this table
- make some change on some feature
- try to display the change of only one feature using the "Feature ID" text field on the plugin UI
expected: the changes are shown
actual: nothing is shown. and on the database log I can see the plugin tries to filter with id
. Ex query:
2021-08-27 15:49:44.558 CEST [811474] postgres@cadastre LOG: statement: SELECT event_id, action_tstamp_clk, schema_name || '.' || table_name, action, application_name, session_user_name, row_data, changed_fields FROM audit.logged_actions l WHERE schema_name = 'public' AND table_name = 'batiments3' AND row_data->'id'='28104' AND action IN ('I','U','D') ORDER BY action_tstamp_clk DESC
(the pk is called ogc_fid
in my case)
Proposed solutions
The audit table keeps track of the pk name, let's use it to filter, instead of id.
This is a bug for TEKSI module wastewater (QGEP) where id are store under the field obj_id.