Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api.exists? raise an error when multiple result found #171

Closed
pierrelegall opened this issue Oct 10, 2023 · 2 comments
Closed

Api.exists? raise an error when multiple result found #171

pierrelegall opened this issue Oct 10, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@pierrelegall
Copy link

pierrelegall commented Oct 10, 2023

Description

Given to the documentation of Api.exists?:

Wether or not the given query would return any results, raising any errors

However, it raise an error when multiple results are found.

To reproduce

# supposing you have multiple users
MyApp.Api.exists?(User)

Raise:

↳ AshPostgres.DataLayer.run_aggregate_query/3, at: lib/data_layer.ex:738
** (Ecto.MultipleResultsError) expected at most one result but got 5 in query:

from u0 in MyApp.User,
  as: 0,
  select: %{}

    (ecto 3.10.3) lib/ecto/repo/queryable.ex:154: Ecto.Repo.Queryable.one/3
    (ash_postgres 1.3.52) lib/data_layer.ex:738: AshPostgres.DataLayer.run_aggregate_query/3
    (ash 2.14.21) lib/ash/actions/aggregate.ex:59: anonymous fn/5 in Ash.Actions.Aggregate.run/4
    (elixir 1.15.6) lib/enum.ex:4830: Enumerable.List.reduce/3
    (elixir 1.15.6) lib/enum.ex:2564: Enum.reduce_while/3
    (djo 0.1.0) lib/djo/api.ex:1: MyApp.Api.exists?/2
    iex:36: (file)

Expected behavior

Api.exists? should return true if multiple results are found.

Runtime

  • Elixir version: 1.15.6
  • Erlang version: 26.1.1
  • OS: Archlinux, Linux 6.5.5-arch1-1
  • ash version: 2.15.10
  • ash_postgres version: 1.3.52
@pierrelegall pierrelegall added bug Something isn't working needs review labels Oct 10, 2023
@zachdaniel
Copy link
Contributor

Something seems strange here for sure, will investigate. You're on the latest version of ash and ash_postgres?

@pierrelegall
Copy link
Author

pierrelegall commented Oct 10, 2023

Yes, I currently use ash v2.15.10 and ash_postgres v1.3.52.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants