Skip to content

fix: correlate bulk upsert records by identity on the MERGE path#786

Merged
zachdaniel merged 1 commit into
ash-project:mainfrom
weljoda:fix/bulk_upsert_managed_relationship_pg_17
Jul 3, 2026
Merged

fix: correlate bulk upsert records by identity on the MERGE path#786
zachdaniel merged 1 commit into
ash-project:mainfrom
weljoda:fix/bulk_upsert_managed_relationship_pg_17

Conversation

@weljoda

@weljoda weljoda commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Summary

Ash.bulk_create/4 with upsert? true plus a manage_relationship/3 change that creates a has_one child can attach children to the wrong parents on PostgreSQL 17+.

The correct logic was already in place, but dead code, because it didn't use the correct variable. So the fix is a simple one line, using the correct variable options instead of opts. The rest is a regression test to reproduce the error.

Because the error is specific to Postgres 17/18 I couldn't reproduce it by running mix test also running it with --include postgres_17 didn't work. I needed to run PG_VERSION=17 mix test --include postgres_17 to reproduce it.

@zachdaniel
zachdaniel merged commit a3e0835 into ash-project:main Jul 3, 2026
115 of 121 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants