test: cover bulk upsert dropping records when select excludes identity keys - #809
Open
marcnnn wants to merge 1 commit into
Open
test: cover bulk upsert dropping records when select excludes identity keys#809marcnnn wants to merge 1 commit into
marcnnn wants to merge 1 commit into
Conversation
…y keys
A bulk upsert pairs each returned row back up with its changeset by the upsert
identity's keys, but the `RETURNING` list is built from the action's
`action_select` alone. When the select doesn't include those keys, every row
reads back with `nil` for each one, nothing correlates, and every record is
dropped from the result - while the rows are still written. The caller sees
`%Ash.BulkResult{status: :success, errors: [], records: []}` for a batch that
inserted or updated fine.
These two tests currently FAIL on main. They are untagged, so they cover both
the `INSERT ... ON CONFLICT` path and the PostgreSQL 17+ `MERGE` path.
`:upsert_with_no_filter` is used because it declares no changes and no
notifiers, which makes its `action_select` just the primary key - an explicit
`select` therefore can't widen it to include the identity key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On upsert the columns that need to be selected to match the updated rows with the rows from the database are not selected anymore so upsert result is empty even if the data is written into the db.
This is a regression that is related to #786 and #638
In my case, an upsert_identity with unique_index defines the upsert semantic already, so the select was left out and is filled by the upsert reactor with the empty list. But the unique index is constructed with two fields not only one like the test, i can add this as well?
My dependabot branch for the ash_postgres update from 2.10.0 to 2.11.0 failed CI
The tests reproduce a simplified version of the problem.
Contributor checklist
Leave anything that you believe does not apply unchecked.