Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapshot views are not accurate #6

Open
jfinzel opened this issue Dec 12, 2019 · 0 comments
Open

Snapshot views are not accurate #6

jfinzel opened this issue Dec 12, 2019 · 0 comments

Comments

@jfinzel
Copy link

jfinzel commented Dec 12, 2019

The *snapshot views created by audit_star are not accurate. In order to show a change history accurately, a recursive query is going to be required. Here is an example of what shows instead of what should be shown in the snapshot view.

Given a record with the following 3 changes, the "customer_id" only gets set to a value on the 3rd change

audit=# SELECT foos_audit_id, changed_at, change FROM service_audit_raw.foos_audit WHERE primary_key = '7068' ORDER BY foos_audit_id;
-[ RECORD 1 ]----------+----------------------------------------------------------------------
foos_audit_id | 2176
changed_at             | 2016-08-14 00:21:13.740758
change                 |
-[ RECORD 2 ]----------+----------------------------------------------------------------------
foos_audit_id | 2177
changed_at             | 2016-08-14 00:21:13.740758
change                 | {"pending": "f", "updated_at": "2016-08-14 00:21:13.807175"}
-[ RECORD 3 ]----------+----------------------------------------------------------------------
foos_audit_id | 2178
changed_at             | 2016-08-14 00:21:13.740758
change                 | {"customer_id": "3215620", "updated_at": "2016-08-14 00:21:13.830382"}

However, here is what the snapshot view actually shows:

audit=# SELECT foos_audit_id, customer_id FROM service_audit.foos_audit_snapshot WHERE primary_key = '7068' ORDER BY foos_audit_id;
-[ RECORD 1 ]----------+--------
foos_audit_id | 2176
customer_id             | 3215620
-[ RECORD 2 ]----------+--------
foos_audit_id | 2177
customer_id             | 3215620
-[ RECORD 3 ]----------+--------
foos_audit_id | 2178
customer_id             | 3215620

It should show NULL for customer_id until the very last record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant