rapidfsub

rapidfsub

This is Product.relationships code.
https://github.com/rapidfsub/sonet/blob/develop/test/support/lib/sonet_lib/seven_eleven/product.ex#L44

This is load test code for above relationships.
https://github.com/rapidfsub/sonet/blob/develop/test/sonet_lib/seven_eleven/product_test.exs#L24

I think three stores, stores_alt1, stores_alt2 relationships should be equivalent.
But, only the stores relationship works,
and other two relationships raise Ecto.Query.CompileError.

I’m confused how to write relationship with no_attributes? true.
Is there any proper way to write this kind of relationships correctly? @zachdaniel

Showing Posts 1 to 10

zachdaniel

zachdaniel

Creator of Ash

What are the details of the error? Just knowing Ecto.Query.CompileError is not really useful without more information.

With that said, could you also describe specifically what the stores relationship is meant to provide?

I can’t really give advice as I don’t know what you’re specifically looking to do.

rapidfsub

rapidfsub OP

Here are the stacktraces.

stacktrace for stores_alt1

  1) test relationships stores (SonetLib.SevenEleven.ProductTest)
     test/sonet_lib/seven_eleven/product_test.exs:24
     ** (Ecto.Query.CompileError) only one distinct expression is allowed in query
     code: Ashex.load!(product, [:stores_alt1])
     stacktrace:
       (ash_postgres 2.4.11) lib/data_layer.ex:1102: AshPostgres.DataLayer.lateral_join_query/3
       (ash_postgres 2.4.11) lib/data_layer.ex:961: AshPostgres.DataLayer.run_query_with_lateral_join/4
       (ash 3.4.35) lib/ash/actions/read/read.ex:2650: Ash.Actions.Read.run_query/4
       (ash 3.4.35) lib/ash/actions/read/read.ex:542: anonymous fn/8 in Ash.Actions.Read.do_read/5
       (ash 3.4.35) lib/ash/actions/read/read.ex:886: Ash.Actions.Read.maybe_in_transaction/3
       (ash 3.4.35) lib/ash/actions/read/read.ex:269: Ash.Actions.Read.do_run/3
       (ash 3.4.35) lib/ash/actions/read/read.ex:81: anonymous fn/3 in Ash.Actions.Read.run/3
       (ash 3.4.35) lib/ash/actions/read/read.ex:80: Ash.Actions.Read.run/3
       (ash 3.4.35) lib/ash/actions/read/relationships.ex:413: anonymous fn/2 in Ash.Actions.Read.Relationships.do_fetch_related_records/4
       (ash 3.4.35) lib/ash/actions/read/relationships.ex:65: Ash.Actions.Read.Relationships.fetch_related_records/4
       (ash 3.4.35) lib/ash/actions/read/relationships.ex:24: Ash.Actions.Read.Relationships.load/4
       (ash 3.4.35) lib/ash/actions/read/read.ex:298: Ash.Actions.Read.do_run/3
       (ash 3.4.35) lib/ash/actions/read/read.ex:81: anonymous fn/3 in Ash.Actions.Read.run/3
       (ash 3.4.35) lib/ash.ex:1859: Ash.load/3
       (ash 3.4.35) lib/ash.ex:1813: Ash.load/3
       (ash 3.4.35) lib/ash.ex:1754: Ash.load!/3
       test/sonet_lib/seven_eleven/product_test.exs:28: (test)

stacktrace for stores_alt2

  1) test relationships stores (SonetLib.SevenEleven.ProductTest)
     test/sonet_lib/seven_eleven/product_test.exs:24
     ** (Ecto.Query.CompileError) only one distinct expression is allowed in query
     code: Ashex.load!(product, [:stores_alt2])
     stacktrace:
       (ash_postgres 2.4.11) lib/data_layer.ex:1102: AshPostgres.DataLayer.lateral_join_query/3
       (ash_postgres 2.4.11) lib/data_layer.ex:961: AshPostgres.DataLayer.run_query_with_lateral_join/4
       (ash 3.4.35) lib/ash/actions/read/read.ex:2650: Ash.Actions.Read.run_query/4
       (ash 3.4.35) lib/ash/actions/read/read.ex:542: anonymous fn/8 in Ash.Actions.Read.do_read/5
       (ash 3.4.35) lib/ash/actions/read/read.ex:886: Ash.Actions.Read.maybe_in_transaction/3
       (ash 3.4.35) lib/ash/actions/read/read.ex:269: Ash.Actions.Read.do_run/3
       (ash 3.4.35) lib/ash/actions/read/read.ex:81: anonymous fn/3 in Ash.Actions.Read.run/3
       (ash 3.4.35) lib/ash/actions/read/read.ex:80: Ash.Actions.Read.run/3
       (ash 3.4.35) lib/ash/actions/read/relationships.ex:413: anonymous fn/2 in Ash.Actions.Read.Relationships.do_fetch_related_records/4
       (ash 3.4.35) lib/ash/actions/read/relationships.ex:65: Ash.Actions.Read.Relationships.fetch_related_records/4
       (ash 3.4.35) lib/ash/actions/read/relationships.ex:24: Ash.Actions.Read.Relationships.load/4
       (ash 3.4.35) lib/ash/actions/read/read.ex:298: Ash.Actions.Read.do_run/3
       (ash 3.4.35) lib/ash/actions/read/read.ex:81: anonymous fn/3 in Ash.Actions.Read.run/3
       (ash 3.4.35) lib/ash.ex:1859: Ash.load/3
       (ash 3.4.35) lib/ash.ex:1813: Ash.load/3
       (ash 3.4.35) lib/ash.ex:1754: Ash.load!/3
       test/sonet_lib/seven_eleven/product_test.exs:32: (test)
rapidfsub

rapidfsub OP

I will explain more about my question.

There are three resources: Store, Inventory, Product.
Store and Product is simple resource, and Inventory is join table resource.

  • Store
    has_many :inventories
  • Product
    has_many :inventories
  • Inventory
    belongs_to :store
    belongs_to :product

I know there is many_to_many feature,
but I wanted to show you there are some hard things when using no_attributes? true.

A private project in our company uses no_attributes? true a lot
(There are some scenarios our company have, only no_attributes? true can be a solution.),
and I meet this kind of error a lot.
How can I avoid these errors and write correct relationship?
Or is this an bug?

zachdaniel

zachdaniel

Creator of Ash

** (Ecto.Query.CompileError) only one distinct expression is allowed in query
is a bug.

Please open a bug report.

zachdaniel

zachdaniel

Creator of Ash

If you can, please provide a reproduction and as much detail as you can. Ideally a test I can run that reproduces the specific error :smiley:

rapidfsub

rapidfsub OP

zachdaniel

zachdaniel

Creator of Ash

Thank you, I’ll take a look in the next day or two.

zachdaniel

zachdaniel

Creator of Ash

This is fixed in main of ash_postgres. I will release new versions of ash and ash_postgres this week.

rapidfsub

rapidfsub OP

Thanks.

rapidfsub

rapidfsub OP

The bug I reported is fixed, but I found another one related to original one.
I opened a new issue in ash_postgres.
https://github.com/ash-project/ash_postgres/issues/413

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews