BryanJBryce

BryanJBryce

Ash Postgres id column error on update

I’ve got an app with multitenency and I’m trying to do a basic update on on resource via GraphQL using the default update action and I’m getting this error:

POST /gql
“superhotel.hotellite.local”
[debug] Processing with Absinthe.Plug
Parameters: %{“operationName” => “UpdateLodgingItem”, “query” => “mutation UpdateLodgingItem($updateLodgingItemId: ID!, $input: UpdateLodgingItemInput) {\n updateLodgingItem(id: $updateLodgingItemId, input: $input) {\n errors {\n code\n fields\n message\n shortMessage\n vars\n }\n result {\n checkInDate\n checkOutDate\n id\n name\n quantity\n rate\n subtotal\n tax\n taxRate\n total\n }\n }\n}”, “variables” => %{“input” => %{“checkInDate” => “2024-05-31”, “checkOutDate” => “2024-06-01”, “name” => “”, “paymentId” => “c252365d-b5c0-4b28-ad17-ccfb70b3d102”, “rate” => “100.0”, “taxRate” => “0.067”}, “updateLodgingItemId” => “0405f3b0-fe49-433d-8b7f-cc7c10b889bb”}}
Pipelines: [:graphql]
“Set tenant to superhotel”
[debug] ABSINTHE schema=App.GraphqlSchema variables=%{“input” => %{“checkInDate” => “2024-05-31”, “checkOutDate” => “2024-06-01”, “name” => “”, “paymentId” => “c252365d-b5c0-4b28-ad17-ccfb70b3d102”, “rate” => “100.0”, “taxRate” => “0.067”}, “updateLodgingItemId” => “0405f3b0-fe49-433d-8b7f-cc7c10b889bb”}

mutation UpdateLodgingItem($updateLodgingItemId: ID!, $input: UpdateLodgingItemInput) {
updateLodgingItem(id: $updateLodgingItemId, input: $input) {
errors {
code
fields
message
shortMessage
vars
}
result {
checkInDate
checkOutDate
id
name
quantity
rate
subtotal
tax
taxRate
total
}
}
}

[debug] QUERY ERROR source=“lodging_items” db=0.0ms queue=2.3ms idle=81.0ms
UPDATE “superhotel”.“lodging_items” AS l0 SET “payment_id” = s1.“payment_id”, “check_out_date” = s1.“check_out_date”, “check_in_date” = s1.“check_in_date”, “rate” = s1.“rate”, “tax_rate” = s1.“tax_rate”, “name” = s1.“name” FROM (SELECT $1::uuid AS “payment_id”, $2::date AS “check_out_date”, $3::date AS “check_in_date”, $4::decimal AS “rate”, $5::decimal AS “tax_rate”, $6::text AS “name” FROM “superhotel”.“lodging_items” AS sl0 WHERE (sl0.“id”::uuid = $7::uuid) LIMIT $8) AS s1 WHERE (l0.“id” = s1.“id”) RETURNING l0.“id”, l0.“name”, l0.“rate”, l0.“check_in_date”, l0.“check_out_date”, l0.“tax_rate”, l0.“payment_id” [“c252365d-b5c0-4b28-ad17-ccfb70b3d102”, ~D[2024-06-01], ~D[2024-05-31], Decimal.new(“100.0”), Decimal.new(“0.067”), nil, “0405f3b0-fe49-433d-8b7f-cc7c10b889bb”, 1]
↳ AshPostgres.DataLayer.update_query/4, at: lib/data_layer.ex:1411
[error] a85087ec-5abb-42a7-86d2-df0f5485f23d: Exception raised while resolving query.

** (Postgrex.Error) ERROR 42703 (undefined_column) column s1.id does not exist

query: UPDATE "superhotel"."lodging_items" AS l0 SET "payment_id" = s1."payment_id", "check_out_date" = s1."check_out_date", "check_in_date" = s1."check_in_date", "rate" = s1."rate", "tax_rate" = s1."tax_rate", "name" = s1."name" FROM (SELECT $1::uuid AS "payment_id", $2::date AS "check_out_date", $3::date AS "check_in_date", $4::decimal AS "rate", $5::decimal AS "tax_rate", $6::text AS "name" FROM "superhotel"."lodging_items" AS sl0 WHERE (sl0."id"::uuid = $7::uuid) LIMIT $8) AS s1 WHERE (l0."id" = s1."id") RETURNING l0."id", l0."name", l0."rate", l0."check_in_date", l0."check_out_date", l0."tax_rate", l0."payment_id"

hint: Perhaps you meant to reference the column "l0.id".

(ecto_sql 3.11.2) lib/ecto/adapters/sql.ex:1054: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto_sql 3.11.2) lib/ecto/adapters/sql.ex:952: Ecto.Adapters.SQL.execute/6
(ecto 3.11.2) lib/ecto/repo/queryable.ex:232: Ecto.Repo.Queryable.execute/4
(ash_postgres 2.0.6) lib/data_layer.ex:1411: AshPostgres.DataLayer.update_query/4
(ash 3.0.8) lib/ash/actions/update/bulk.ex:442: Ash.Actions.Update.Bulk.do_atomic_update/5
(ash 3.0.8) lib/ash/actions/update/bulk.ex:231: Ash.Actions.Update.Bulk.run/6
(ash_graphql 1.0.1) lib/graphql/resolver.ex:1224: AshGraphql.Graphql.Resolver.mutate/2
(absinthe 1.7.6) lib/absinthe/phase/document/execution/resolution.ex:234: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
(absinthe 1.7.6) lib/absinthe/phase/document/execution/resolution.ex:189: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/3
(absinthe 1.7.6) lib/absinthe/phase/document/execution/resolution.ex:174: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
(absinthe 1.7.6) lib/absinthe/phase/document/execution/resolution.ex:145: Absinthe.Phase.Document.Execution.Resolution.resolve_fields/4
(absinthe 1.7.6) lib/absinthe/phase/document/execution/resolution.ex:88: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
(absinthe 1.7.6) lib/absinthe/phase/document/execution/resolution.ex:67: Absinthe.Phase.Document.Execution.Resolution.perform_resolution/3
(absinthe 1.7.6) lib/absinthe/phase/document/execution/resolution.ex:24: Absinthe.Phase.Document.Execution.Resolution.resolve_current/3
(absinthe 1.7.6) lib/absinthe/pipeline.ex:408: Absinthe.Pipeline.run_phase/3
(absinthe_plug 1.5.8) lib/absinthe/plug.ex:536: Absinthe.Plug.run_query/4
(absinthe_plug 1.5.8) lib/absinthe/plug.ex:290: Absinthe.Plug.call/2
(phoenix 1.7.12) lib/phoenix/router/route.ex:42: Phoenix.Router.Route.call/2
(phoenix 1.7.12) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
(app 0.1.0) lib/app_web/endpoint.ex:1: AppWeb.Endpoint.plug_builder_call/2

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

Should be fixed in latest ash_postgres main, thanks :slight_smile:

Also Liked

zachdaniel

zachdaniel

Creator of Ash

:cry: okay in that case please open an issue in ash_postgres and I will look into it as soon as I am able :+1:

Last Post!

BryanJBryce

BryanJBryce

Hrm, the sample project didn’t reproduce, could be a bug on my end

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54260 488
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49266 226
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement