clemensm

clemensm

Hi everyone

I’ve updated to Ash version 3.24.3 from 3.9.0, and since the update one part of the code no longer works. Basically the situation is like this, there is a main Resource `resource`, another resource `family`, and they are joined using a join table `family_membership`. So they look roughly like this:

defmodule MyApp.FamilyMembership do
  use Ash.Resource,
    domain: MyApp.Domain,
    data_layer: AshPostgres.DataLayer

  postgres do
    table "family_memberships"
    repo MyApp.Repo
  end

  attributes do
    uuid_primary_key :id
  end

  relationships do
    belongs_to :resource, MyApp.MyResource, primary_key?: true, allow_nil?: false
    belongs_to :family, MyApp.Family, primary_key?: true, allow_nil?: false
  end
end

and both resource have the many_to_many relationship defined, like this for the `resource`:

relationships do
  many_to_many :families, MyApp.Family do
    through MyApp.FamilyMembership
    source_attribute_on_join_resource :resource_id
    destination_attribute_on_join_resource :family_id
  end
end

and like this for the `family`:

relationships do
  many_to_many :resources, MyApp.MyResource do
    through MyApp.FamilyMembership
    source_attribute_on_join_resource :family_id
    destination_attribute_on_join_resource :resource_id
  end
end

All three modules are registered in the Domain.

Now when I try to run a query like this:

MyApp.Resource |> Ash.Query.filter(exists(families, id == 8)) |> Ash.read!()

I always get this error, and have no clue how to fix that:

** (Ash.Error.Unknown)
Bread Crumbs:
  > Exception raised in: Prices.Data.Part.for_load

Unknown Error

* ** (ArgumentError) `nil` is not a Spark DSL module.

  nil.fetch_opt([:multitenancy], :strategy)
  (spark 2.6.1) lib/spark/dsl/extension.ex:2162: Spark.Dsl.Extension.get_config_entry_with_fallback/6
  (spark 2.6.1) lib/spark/dsl/extension.ex:307: Spark.Dsl.Extension.get_opt/5
  (ash_sql 0.3.11) lib/join.ex:604: AshSql.Join.join_prefix/3
  (ash_sql 0.3.11) lib/join.ex:600: AshSql.Join.set_join_prefix/3
  (ash_sql 0.3.11) lib/join.ex:494: AshSql.Join.related_query/3
  (ash_sql 0.3.11) lib/join.ex:348: AshSql.Join.related_subquery/3
  (ash_sql 0.3.11) lib/join.ex:909: AshSql.Join.join_relationship/8
  (ash_sql 0.3.11) lib/join.ex:161: anonymous fn/10 in AshSql.Join.join_all_relationships/10
  (elixir 1.18.4) lib/enum.ex:4968: Enumerable.List.reduce/3
  (elixir 1.18.4) lib/enum.ex:2600: Enum.reduce_while/3
  (ash_postgres 2.6.25) lib/data_layer.ex:3507: AshPostgres.DataLayer.filter/4
  (ash 3.24.3) lib/ash/actions/read/read.ex:88: Ash.Actions.Read.run/3
    nil.fetch_opt([:multitenancy], :strategy)
    (spark 2.6.1) lib/spark/dsl/extension.ex:2162: Spark.Dsl.Extension.get_config_entry_with_fallback/6
    (spark 2.6.1) lib/spark/dsl/extension.ex:307: Spark.Dsl.Extension.get_opt/5
    (ash_sql 0.3.11) lib/join.ex:604: AshSql.Join.join_prefix/3
    (ash_sql 0.3.11) lib/join.ex:600: AshSql.Join.set_join_prefix/3
    (ash_sql 0.3.11) lib/join.ex:494: AshSql.Join.related_query/3
    (ash_sql 0.3.11) lib/join.ex:348: AshSql.Join.related_subquery/3
    (ash_sql 0.3.11) lib/join.ex:909: AshSql.Join.join_relationship/8
    (ash_sql 0.3.11) lib/join.ex:161: anonymous fn/10 in AshSql.Join.join_all_relationships/10
    (elixir 1.18.4) lib/enum.ex:4968: Enumerable.List.reduce/3
    (elixir 1.18.4) lib/enum.ex:2600: Enum.reduce_while/3
    (ash_postgres 2.6.25) lib/data_layer.ex:3507: AshPostgres.DataLayer.filter/4
    (ash 3.24.3) lib/ash/behaviour_helpers.ex:62: Ash.BehaviourHelpers.call_and_validate_return/5
    (ash 3.24.3) lib/ash/query/query.ex:4769: Ash.Query.maybe_filter/3
    (ash 3.24.3) lib/ash/query/query.ex:4520: Ash.Query.data_layer_query/2
    (ash 3.24.3) lib/ash/actions/read/read.ex:801: anonymous fn/9 in Ash.Actions.Read.do_read/5
    (ash 3.24.3) lib/ash/actions/read/read.ex:1601: Ash.Actions.Read.maybe_in_transaction/3
    (ash 3.24.3) lib/ash/actions/read/read.ex:435: Ash.Actions.Read.do_run/3
    (ash 3.24.3) lib/ash/actions/read/read.ex:89: anonymous fn/3 in Ash.Actions.Read.run/3
    iex:22: (file)

To me it looks like I need to preload the `:families`, but adding a `Ash.Query.load(:families)` does not help at all. Also this was working fine before the upgrade.

Any help on how to fix this is appreciated :slightly_smiling_face:

Showing Posts 1 to 2

zachdaniel

zachdaniel

Creator of Ash

The bug is caused by an issue in ash_postgres. Please update ash_postgres and ash_sql as well :person_bowing:

clemensm

clemensm OP

Thanks, should have thought about updating those as well…. :upside_down_face:

— All posts loaded —

Where Next? Top

Trending in Questions Top

Hellowman
Hello everyone! I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++. Does anyone ...
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
Fl4m3Ph03n1x
Background When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error: * assembling mark...
New
mandar1045
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
saleyn
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
261 13183 112
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews