Skip to content

Conversation

barnabasJ
Copy link
Contributor

should fix #637

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

@barnabasJ barnabasJ force-pushed the fix/return-correct-values-from-bulk-create-if-values-are-generated-in-the-datalayer branch from c76f561 to 39499c6 Compare October 15, 2025 11:42
changeset.attributes
|> Map.take(keys)
cant_map_results_to_changesets =
any_generated_keys_missing?(keys, resource, changesets)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I don't see how this is possible? Don't we require the keys to be given to do an upsert on them? And this is only inside the upsert branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part happens regardless, there is another if further on top that we only enter on upserts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, then we should switch back to index based when it's not an upsert. If it's just a create, either they are all created or not, there is no variability. Can you make that change?

If the identity used has attibutes that can be generated by the
datalayer, we can't map the result back to the changeset and we need to
just zip the results with the changesets and return them that way.
@barnabasJ barnabasJ force-pushed the fix/return-correct-values-from-bulk-create-if-values-are-generated-in-the-datalayer branch from 39499c6 to 522191c Compare October 16, 2025 08:57
@zachdaniel zachdaniel merged commit f9bd171 into main Oct 16, 2025
65 of 67 checks passed
@zachdaniel
Copy link
Contributor

🚀 Thank you for your contribution! 🚀

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.

Ash.bulk_create/4 returns empty list records when using integer primary keys

2 participants