return=representation returns old values of updatable view #2393
-
Environment
Description of issuePostgrest returns old values of query parameters Sample RequestPATCH /test?row_id=eq.1&version_id=eq.1 { “name”: “new_name” } Expected behavior:Postgrest returns accurate representation of all table fields Cause of behaviorDatabase trigger updates version_id field on row update. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Please share the response you expect. Also a curl snippet would be helpful. |
Beta Was this translation helpful? Give feedback.
-
It appears that this situation only occurs when updating a view. When I update a table I get the response I expect. My apologies for not finding this out earlier. In case this still might be of interest... This view has a table with a before update trigger that sets Expected response: {id: 1, vid: 2, some_field: "new_value"} curl "http://server.local:9200/api/updateable_view?id=eq.1" |
Beta Was this translation helpful? Give feedback.
-
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:
Behavior:
|
Beta Was this translation helpful? Give feedback.
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:
example: NEW.field = OLD.field + 1
example: INSTEAD OF UPDATE ON table...
example: UPDATE table|view ... RETURNING *
Behavior: