Skip to content

0.8.2

Choose a tag to compare

@fatbobman fatbobman released this 10 Mar 12:22
· 53 commits to main since this release

CoreDataEvolution 0.8.2

0.8.2 is a significant update to generated relationship APIs for @PersistentModel.

This release makes to-many relationship mutation more explicit, more consistent, and much closer to the way Core Data relationship helpers are typically used in practice.

Highlights

  • to-many relationship properties no longer generate setters
  • unordered Set<T> relationships now generate both single-value and batch helpers
  • ordered [T] relationships now generate both single-value and batch helpers, plus indexed insertion
  • macro diagnostics, snapshot baselines, runtime integration tests, and documentation are all updated to match the new rules

Relationship API Changes

To-one relationships

To-one properties keep the current behavior:

  • getter
  • setter

Unordered to-many relationships

For unordered relationships declared as Set<T>, the macro now generates:

  • addTo<Property>(_ value: T)
  • removeFrom<Property>(_ value: T)
  • addTo<Property>(_ values: Set<T>)
  • removeFrom<Property>(_ values: Set<T>)

Ordered to-many relationships

For ordered relationships declared as [T], the macro now generates:

  • addTo<Property>(_ value: T)
  • removeFrom<Property>(_ value: T)
  • addTo<Property>(_ values: [T])
  • removeFrom<Property>(_ values: [T])
  • insertInto<Property>(_ value: T, at index: Int)

Breaking Change

To-many relationship properties no longer generate setters.

That means code like direct assignment to a Set<T> or [T] relationship property is no longer part of the generated API surface. Relationship mutation should now go through the generated helper methods.

This applies to both:

  • unordered to-many relationships (Set<T>)
  • ordered to-many relationships ([T])

Why This Change

This update intentionally pushes relationship mutation toward explicit helper methods instead of whole-collection replacement.

That gives the generated API a clearer shape:

  • T?: direct property assignment
  • Set<T> / [T]: helper-based relationship mutation

It also lets the macro provide a richer and more ergonomic relationship surface than the previous minimal helper set.

Validation

The new behavior is covered by:

  • macro expansion snapshot tests
  • macro diagnostic tests
  • integration tests for unordered and ordered relationship helper behavior
  • updated user and development documentation