kvesteri / postgresql-audit

Audit trigger for PostgreSQL
BSD 2-Clause "Simplified" License
127 stars 28 forks source link

Flask Migration Issue #43

Closed zzachattack2 closed 4 months ago

zzachattack2 commented 5 years ago

I've been having issue installing within flask with the following error:

File "/.local/share/virtualenvs/backend-Xo4Co4k2/lib/python3.7/site-packages/sqlalchemy/util/_collections.py", line 194, in __getitem__ return self._data[key] KeyError: "tsrange(issued_at - INTERVAL '1 hour', issued_at)"

Seems to be based on the following from the alembic migration script: postgresql.ExcludeConstraint((sa.column('native_transaction_id'), '='), ("tsrange(issued_at - INTERVAL '1 hour', issued_at)", '&&'), using='gist', name='transaction_unique_native_tx_id')

Tested on both postgres 10 and 11. Any suggestions?

wakemaster39 commented 4 years ago

Through many hours of digging on this exact same issue, I believe the problem is the raw text and it not being sql. wrapping the text in text treats it as sql and it then proceeded to work.

postgresql.ExcludeConstraint((sa.column('native_transaction_id'), '='), (text("tsrange(issued_at - INTERVAL '1 hour', issued_at)"), '&&'), using='gist', name='transaction_unique_native_tx_id'),

I still have some more testing to do to make sure it works. I am also not sure if this is a recommended approach to fixing the issue.

thapakaazzi commented 3 years ago

any progress on this issue???