Ash FrameworkAF
Ash Frameworkโ€ข3y agoโ€ข
4 replies
richaard0

Expected at most one result but got ...

I'm not sure if I've encountered a bug or not.

I have the following action:
read :get do
  argument :id, :uuid
  get? true
end


and the following associated code interface:

define :get do
  args [:id]
end


I expect it to return at most one result.

In iex, if I call the following:
iex(11)> Flight.get("a8c463a0-2ae0-4f04-8fbe-7bb1abe94ff6", tenant: "8f251331-d27b-4d42-a05b-5dbe3e019ebe")


I receive the following error:
{:error,
 %Ash.Error.Invalid{
   errors: [
     %Ash.Error.Invalid.MultipleResults{
       count: 5,
    .....
}


I confirmed that my record exists and that there is only one in my DB. More interestingly, here's the query that's being performed:

[debug] QUERY OK source="flights" db=11.9ms queue=0.1ms idle=283.7ms
SELECT f0."id", f0."number", f0."departure_time", f0."arrival_time", f0."airline_id", f0."departure", f0."arrival", f0."alternate", f0."user_id", f0."plane_id" FROM "flights" AS f0 WHERE (f0."airline_id"::uuid = $1::uuid) ["8f251331-d27b-4d42-a05b-5dbe3e019ebe"]

I only see a check for the tenant here (airline_id) and not the id of the flight.

Am I missing something super obvious in my resource or is this a bug?

Thanks a lot it in advance! ๐Ÿ˜€
Was this page helpful?