Skip to content

return=representation returns old values of updatable view #2393

Answered by MadMartigan
MadMartigan asked this question in Q&A
Discussion options

You must be logged in to vote

This seems to be standard Postgres behavior. This is definitely not a postgREST issue or bug.

TLDR:

Updatable views that contain tables with triggers may return unexpected results

Setup:

  1. Create a before update trigger on a table that increments an integer field. example: NEW.field = OLD.field + 1
  2. Create an updatable view that contains that table. example: INSTEAD OF UPDATE ON table...
  3. Perform an update on both the table and view and return the results. example: UPDATE table|view ... RETURNING *

Behavior:

  • Table update will return incremented value
  • View update will return non-incremented value

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@steve-chavez
Comment options

@MadMartigan
Comment options

@wolfgangwalther
Comment options

Answer selected by steve-chavez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2392 on July 27, 2022 17:20.