You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error: error: select "orders".*, "locations"."organization_id" as
"through_organization_id" from "orders" inner join "locations" on "locations"."id" =
"orders"."location_id" where "id" = $1 and "locations"."organization_id" = $2 and
"orders"."deleted_at" is null limit $3 - column reference "id" is ambiguous
Notes
Manually adjusting the findRelatedForRequest query to prefix id with the table name works!
in Organization.ts:
public findRelatedForRequest(ctx, param, value) {
/**
* Have to do this weird dance because of
* https://github.com/microsoft/TypeScript/issues/37778
*/
const self = this as unknown as Organization;
return self.related('orders').query().where('orders.id', value).firstOrFail();
}
The table name (orders) prefix makes the query work.
BONUS (a sample repo to reproduce the issue)
I can set this up if need be! Please let me know.
The text was updated successfully, but these errors were encountered:
Package version
1.0.1
Node.js and npm version
postgres version: 15.4
Issue
I'm getting a postgres error that the provided
id
column is ambiguous.Sample Code (to reproduce the issue)
I have the following model setup:
An
Organization
hasManyLocations
A
Location
hasManyOrders
Now I'm setting up a relationship so that I can fetch all orders that belong to an organization:
An
Organization
hasManyThrough[Location, Order]
.Here is the (reduced) code for my models:
I'm declaring a route using route-model binding:
And I'm declaring a controller like this:
When I hit this route, I get the following error:
Notes
Manually adjusting the
findRelatedForRequest
query to prefixid
with the table name works!in Organization.ts:
The table name (
orders
) prefix makes the query work.BONUS (a sample repo to reproduce the issue)
I can set this up if need be! Please let me know.
The text was updated successfully, but these errors were encountered: