ash icon indicating copy to clipboard operation
ash copied to clipboard

Don't run queries with `filter: false`

Open barnabasJ opened this issue 2 years ago • 2 comments

Describe the bug A clear and concise description of what the bug is.

A query is done even though the filter can never be true

example SQL from a query of a many_to_many with an empty join_relationship table

[debug] QUERY OK source="file_reference" db=0.3ms queue=0.4ms idle=1255.7ms
SELECT i0."invoice_id", i0."file_id", i0."id" FROM "file_reference" AS i0 WHERE (i0."invoice_id"::uuid IN ($1::uuid)) ["a166ec6a-a217-4868-9033-efc5cd8f4e0d"]
↳ anonymous fn/3 in AshPostgres.DataLayer.run_query/2, at: lib/data_layer.ex:706
[debug] QUERY OK source="file" db=9.7ms queue=0.9ms idle=1263.9ms
SELECT DISTINCT ON (f0."id") f0."updated_at", f0."created_at", f0."updated_by", f0."created_by", f0."id", f0."external_id", f0."external_provider", f0."meta", f0."description_de", f0."description_en" FROM "file" AS f0 INNER JOIN "public"."incoming_invoice_file_reference" AS i1 ON f0."id" = i1."file_id" WHERE (false)

Not necessarily a bug but the query could be omitted

To Reproduce A minimal set of resource definitions and calls that can reproduce the bug.

create a many_to_many and do not create any references query for the relationship

Expected behavior A clear and concise description of what you expected to happen.

Runtime

  • Elixir version
  • Erlang version
  • OS
  • Ash version
  • any related extension versions

Additional context Add any other context about the problem here.

barnabasJ avatar May 22 '24 08:05 barnabasJ

I'll work on a fix

jbfawcett24 avatar Sep 29 '26 19:09 jbfawcett24

👋 this one is already fixed, the issue just wasn't closed. Sorry!

zachdaniel avatar Sep 29 '26 22:09 zachdaniel