Skip to content

feat: add touch_update_defaults? option to bulk_create#2590

Merged
zachdaniel merged 3 commits intoash-project:mainfrom
mbaertschi:feat/touch-update-defaults
Feb 27, 2026
Merged

feat: add touch_update_defaults? option to bulk_create#2590
zachdaniel merged 3 commits intoash-project:mainfrom
mbaertschi:feat/touch-update-defaults

Conversation

@mbaertschi
Copy link
Contributor

@mbaertschi mbaertschi commented Feb 25, 2026

Allows callers to skip updating update_default fields (like updated_at) when a bulk_create upsert results in an update. Supported in ETS and Mnesia data layers.

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

Allows callers to skip updating update_default fields (like updated_at)
when a bulk_create upsert results in an update. Supported in ETS and
Mnesia data layers.
mbaertschi added a commit to mbaertschi/ash_sqlite that referenced this pull request Feb 25, 2026
…et context

Read the touch_update_defaults? flag from the bulk_create options map
rather than from changeset context.

Depends on ash-project/ash#2590 which adds touch_update_defaults? to the
options passed to data layers. Only merge once that PR is merged and released.
mbaertschi added a commit to mbaertschi/ash_postgres that referenced this pull request Feb 25, 2026
…et context

Read the touch_update_defaults? flag from the bulk_create options map
rather than from changeset context.

Depends on ash-project/ash#2590 which adds touch_update_defaults? to the
options passed to data layers. Only merge once that PR is merged and released.
When touch_update_defaults? is false, update_default fields that were
explicitly included in upsert_fields or set by the user on the changeset
are now preserved instead of being stripped. Also wires touch_update_defaults?
through Ash.create! for non-bulk upserts via a new upsert/5 data layer callback.
@mbaertschi
Copy link
Contributor Author

hei @zachdaniel besides the two issues you mentioned, I also added this feature to the non-bulk upsert path. Do you agree? I have to backport this to the ash_postgres and ash_sqlite data layers as well

@mbaertschi
Copy link
Contributor Author

ash-project/ash_sqlite#208 and ash-project/ash_postgres#701 now both respect the non-bulk path as well

@zachdaniel
Copy link
Contributor

zachdaniel commented Feb 26, 2026

I like the addition of the feature, but for non bulk I'd prefer it to be communicated via the changeset context. Adding an opts arg for arbitrary stuff isn't something I'd prefer to do in the data layer behavior if it can be avoided.

@zachdaniel zachdaniel merged commit 47afba5 into ash-project:main Feb 27, 2026
45 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.

2 participants