Skip to content

Fix: Enable composite types to act as maps in queries and calculations - #3045

Merged
zachdaniel merged 1 commit into
ash-project:mainfrom
noelgbl:fix/composite-types-act-as-map
Oct 19, 2026
Merged

zachdaniel merged 1 commit into
ash-project:mainfrom
noelgbl:fix/composite-types-act-as-map

Conversation

@noelgbl

@noelgbl noelgbl commented Oct 19, 2026

Copy link
Copy Markdown

Since function arguments are checked against their declared types (#2948), get_path refuses composite types. Ash.Query.Function.GetPath declares :map for its first argument, and a composite type neither is :map nor acts as one. #2948 gave acts_as(_), do: :map to structs, tuples, keywords and embedded resources, but not to composite types.

As a result, every read that uses get_path, attr[:field] or the at_path input predicate on a composite attribute raises, including the usage documented under "Composite Types" in Ash.Type:

Ash.Query.filter(expr(coordinates[:x] == 1))
`get_path` cannot be applied to `coordinates`: 1st argument must be one of :map, but `coordinates` is of type MyApp.Point

This worked for me before 3.33.6, both in data layers that compile composite paths via composite_types/1 and in memory.

Change

  • When a type returns true from composite?/1 and nil from acts_as/1, Ash.Type.acts_as/2 now falls back to :map.
    • A type that declares its own acts_as/1 keeps that answer.
    • Arrays of composite types act as {:array, :map}.
    • A NewType over a composite type is covered too, since composite?/1 passes through to the subtype.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • [x ] I accept the AI Policy, or AI was not used in the creation of this PR.
  • [ x] Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@zachdaniel
zachdaniel merged commit 5edd38c into ash-project:main Oct 19, 2026
@zachdaniel

Copy link
Copy Markdown
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