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

Trigger not working if table contains column with non-equality type #33

Closed
dzolo opened this issue May 11, 2022 · 6 comments · Fixed by #34
Closed

Trigger not working if table contains column with non-equality type #33

dzolo opened this issue May 11, 2022 · 6 comments · Fixed by #34

Comments

@dzolo
Copy link
Contributor

dzolo commented May 11, 2022

If the table contains a column which does not implement equality operator then the versioning trigger fails. The equality operator is not implemented for some PostGIS data types, JSON data types, etc.

Example error for table with PostGIS polygon type:

ERROR:  could not identify an equality operator for type polygon
CONTEXT:  PL/pgSQL function versioning() line 38 at IF

The reason is the NEW IS NOT DISTINCT FROM OLD statement in IF condition related to the ignore_unchanged_values feature. The failure occurs even if the ignore_unchanged_values is not enabled as all parts of the IF condition are executed. Thus the issue is quite severe as it breaks compatibility/functionality with the old fashion temporal_tables.

@simoneb
Copy link
Member

simoneb commented May 11, 2022

@dzolo any thoughts about what would be a sensible solution?

@dzolo
Copy link
Contributor Author

dzolo commented May 11, 2022

@simoneb simple solution for ignore_unchanged_values=false is to use nested if:

  IF ignore_unchanged_values AND TG_OP = 'UPDATE' THEN
    IF NEW IS NOT DISTINCT FROM OLD THEN
      RETURN OLD;
    END IF;
  END IF;

For the ignore_unchanged_values=true I down think that there will be an easy solution to this. Probably the ignore_unchanged_values feature will not be possible for such tables.

dzolo added a commit to dzolo/neatform_temporal_tables that referenced this issue May 11, 2022
@dzolo
Copy link
Contributor Author

dzolo commented May 11, 2022

I have created a PR at least for the ignore_unchanged_values=false

@simoneb
Copy link
Member

simoneb commented May 11, 2022

Amazing thanks. Do you think it would be possible to include a test?

@dzolo
Copy link
Contributor Author

dzolo commented May 11, 2022

OK, will do later.

dzolo added a commit to dzolo/neatform_temporal_tables that referenced this issue May 11, 2022
simoneb pushed a commit that referenced this issue Jul 25, 2023
…ignore_unchanged_values=false (#34)

* #33: Fix trigger if table contains column with non-equality type for ignore_unchanged_values=false

* #33: Add positive and negative tests

* Fix invalid conflict resolving.
@github-actions
Copy link

🎉 This issue has been resolved in version 0.5.0 🎉

The release is available on:

Your optic bot 📦🚀

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