ash-project / ash-project/ash_postgres

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

Open
#239 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Elixir
Stars
189
Forks
168
Avg merge
13h 1m
Merged PRs (30d)
22

Description

**Describe the bug**
It is the same issue like https://github.com/ash-project/ash_postgres/issues/173. Having the following relationship:

```elixir
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.