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
SELECT"order".*,
"order_items"."id"AS"order_items.id",
"order_items"."price"AS"order_items.price",
"order_items"."item_id"AS"order_items.item_id"FROM (
SELECT"order"."id",
"order"."transaction_no",
"order"."description",
"order_items.item"."id"AS"order_items.item.id",
"order_items.item"."name"AS"order_items.item.name",
"order_items.item.item_group"."id"AS"order_items.item.item_group.id",
"order_items.item.item_group"."name"AS"order_items.item.item_group.name",
FROM"order"AS"order"INNER JOIN"item"AS"order_items.item"ON"order_items"."item_id"="order_items.item"."id"AND"order_items.item"."deleted_at" IS NULLINNER JOIN"item_group"AS"order_items.item.item_group"ON"order_items.item"."item_group_id"="order_items.item.item_group"."id"AND"order_items.item.item_group"."deleted_at" IS NULLWHERE"order"."deleted_at" IS NULLAND (
SELECT"order_id"FROM"order_item"AS"order_item"WHERE (
"order_item"."order_id"="order"."id"AND"order_item"."deleted_at" IS NULL
)
LIMIT1
) IS NOT NULLLIMIT20
OFFSET 0
) AS"order"INNER JOIN"order_item"AS"order_items"ON"order"."id"="order_items"."order_id"AND"order_items"."deleted_at" IS NULL;
What is actually happening?
The query produce error:
missing FROM-clause entry for table "order_items"
I know this happen because "order_items" called in subQuery, while it define in the outer query
What do I expect to happen?
I have a list with filter form to search in table "order", "order_item", "item", "item_group", and I need limitation for pagination of "Order" list. I understand sequelize should make subQuery of table "order" to make the limitation on "Order" list works (so I can't add option "subQuery: false"). But my question is why table "item" and "item_group" appears inside the subQuery of table "order" while its association is at outer query? How to send table "item" and "item_group" to outer query? So the generated query should be more like:
SELECT"order".*,
"order_items"."id"AS"order_items.id",
"order_items"."price"AS"order_items.price",
"order_items"."item_id"AS"order_items.item_id",
"order_items.item"."id"AS"order_items.item.id",
"order_items.item"."name"AS"order_items.item.name",
"order_items.item.item_group"."id"AS"order_items.item.item_group.id",
"order_items.item.item_group"."name"AS"order_items.item.item_group.name"FROM (
SELECT"order"."id",
"order"."transaction_no",
"order"."description"FROM"order"AS"order"WHERE"order"."deleted_at" IS NULLLIMIT20
OFFSET 0
) AS"order"INNER JOIN"order_item"AS"order_items"ON"order"."id"="order_items"."order_id"AND"order_items"."deleted_at" IS NULL-- [orderItemConditions]INNER JOIN"item"AS"order_items.item"ON"order_items"."item_id"="order_items.item"."id"AND"order_items.item"."deleted_at" IS NULL-- [itemConditions]INNER JOIN"item_group"AS"order_items.item.item_group"ON"order_items.item"."item_group_id"="order_items.item.item_group"."id"AND"order_items.item.item_group"."deleted_at" IS NULL;
-- [itemGroupConditions]
What I am doing?
So I have this below query:
The association at "order" model
This association at "order_item" model
The association at "item" model
The association at "item_group" model
And the generated query is:
What is actually happening?
The query produce error:
I know this happen because "order_items" called in subQuery, while it define in the outer query
What do I expect to happen?
I have a list with filter form to search in table "order", "order_item", "item", "item_group", and I need limitation for pagination of "Order" list. I understand sequelize should make subQuery of table "order" to make the limitation on "Order" list works (so I can't add option "subQuery: false"). But my question is why table "item" and "item_group" appears inside the subQuery of table "order" while its association is at outer query? How to send table "item" and "item_group" to outer query? So the generated query should be more like:
__Dialect: PostgreSQL
__Database version: 9.4.10
__Sequelize version: 3.22.0
The text was updated successfully, but these errors were encountered: