Skip to content

[PPS-34428] Mongoid 8.1.13 fork overrides (Rails 8.1 bound, batch insert, validate all children) - #3

Open
gloox wants to merge 6 commits into
upstream-v8.1.13from
PPS-34428-restore-batch-insert
Open

gloox wants to merge 6 commits into
upstream-v8.1.13from
PPS-34428-restore-batch-insert

Conversation

@gloox

@gloox gloox commented Oct 28, 2026 •

Copy link
Copy Markdown

For visibility only; this is not meant to be merged. supply_chain pins to the tag cut from this branch (v8.1.13-sc.3).

Upstream Mongoid 8.1.13 plus the overrides from the previous fork, some overrides are removed as they were adresssed in 8.1.13 and others were added as a result of some behaviour changes. Each override's code comment explains why it exists, how to remove it, and what can break when rebasing.

  • activemodel bound (mongoid.gemspec): widened to < 8.2 so 8.1.x works with Rails 8.1. Upstream did this on master/9.0-stable only.
  • Batch insert (Batchable#pre_process_batch_insert): restores the pre-8.1.12 one-at-a-time append. MONGOID-4889's rewrite drops children built with the inverse set and re-sorts assigned batches.
  • Validate all children (AssociatedValidator#validate_association): validates every child, not only new or changed ones. Upstream reverted its fix (MONGOID-5822, MONGOID-5848 Revert MONGOID-5822 (8.1 backport) mongodb/mongoid#6014).

Specs are in spec/mongoid/association/embedded/embeds_many/batch_insert_spec.rb and spec/mongoid/validatable/associated_all_children_spec.rb. They have not been run in this repo; supply_chain's own specs for both behaviors are the check.

gloox and others added 3 commits October 23, 2026 08:48
Mongoid 8.1.12 (MONGOID-4889) rewrote Batchable#pre_process_batch_insert to
use append_many, which drops children built with the inverse already set and
re-sorts assigned batches by the relation order. Restore the one-at-a-time
append version, document how to remove it, and add specs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@gloox
gloox changed the base branch from PPS-34428-8.1.13-support-rails-8-1 to upstream-v8.1.13 October 28, 2026 13:32
… ones

Upstream only validates children that are new or changed, so a child
validation that depends on the parent is skipped when only the parent
changes. Upstream tried to fix this (MONGOID-5822) and reverted it (mongodb#6014).
Restore validating all children, skipping those flagged for destroy.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@gloox gloox changed the title [PPS-34428] Restore pre-8.1.12 embedded batch insert behavior [PPS-34428] Mongoid 8.1.13 fork overrides (Rails 8.1 bound, batch insert, validate all children) Oct 28, 2026
gloox and others added 2 commits October 29, 2026 08:11
…ciation

The previous override read the association via read_attribute_for_validation,
which loads it. Saving a parent then validated children nothing touched, so
legacy data in an unloaded embedded child (e.g. a Property's Address with
region "Stowe - VT") made unrelated saves fail.

Go back to the old 8.1-stable-sc behavior: inspect the proxy through ivar so
nothing is loaded, and validate every loaded child, new or not.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ole association"

The old 8.1.7 fork loaded and validated every child, so v8.1.13-sc.3 matches it.
Not loading broke property_import_spec in supply_chain.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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