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

has_one with no_attributes? true and from_many? true does not apply limiting to the query #239

Open
smt116 opened this issue Apr 17, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@smt116
Copy link

smt116 commented Apr 17, 2024

Describe the bug
It is the same issue like #173. Having the following relationship:

has_one :latest_exchange_rate, App.Resources.ExchangeRate do
  api App.Api
  from_many? true
  no_attributes? true
  private? true
  sort inserted_at: :desc
end

Ignores from_many?: true and assigns a list of all records. I can see that the SQL query does not include the LIMIT statement.

Expected behavior
It should include LIMIT 1 in the SQL query and make the relationship refer to a single entity.

Runtime

  • Elixir version 1.15.7-otp-26
  • Erlang version 26.0.2
  • OS macOS
  • Ash version 2.21.2
  • Ash Postgres version 1.5.23
@smt116 smt116 added bug Something isn't working needs review labels Apr 17, 2024
@zachdaniel
Copy link
Contributor

Is this when loading the relationship? In what context did you observe this behavior?

@zachdaniel
Copy link
Contributor

oh, I see. its not honoring it in exists? Interesting...

@smt116
Copy link
Author

smt116 commented Apr 19, 2024

Is this when loading the relationship? In what context did you observe this behavior?

Yes. When I App.API.load!(record, :this_relation), the record.this_relation will include all the records from the database instead of just that one defined by the relation (from many + sorting).

@zachdaniel
Copy link
Contributor

zachdaniel commented Apr 20, 2024

I can't reproduce this. I think we'll need either an example test case or a reproduction project to move forward. The 2.0 github branch is up to date with the latest 2.0 version.

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