Skip to content

Add partial identity join sorting test#778

Open
jechol wants to merge 1 commit into
ash-project:mainfrom
jechol:test/many-to-many-partial-identity-sort
Open

Add partial identity join sorting test#778
jechol wants to merge 1 commit into
ash-project:mainfrom
jechol:test/many-to-many-partial-identity-sort

Conversation

@jechol

@jechol jechol commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a regression test for sorting a many_to_many relationship by a join resource attribute when the join resource uses a partial identity.

This covers the behavior fixed in ash-project/ash#2746.

The test uses a polymorphic join resource shape where multiple nullable foreign keys can exist on the same resource, but only the post_id / user_id pair is unique when both keys are present:

identity :post_user, [:post_id, :user_id],
  where: expr(not is_nil(post_id) and not is_nil(user_id))

The loaded relationship then sorts through the join relationship field:

sort: [Ash.Sort.expr_sort(parent(user_notification_recipients.order), :integer)]

Notes

This test fixture mirrors polymorphic ordered join resources where a partial identity guarantees one join row for a specific source/destination pair.

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

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.

1 participant