fixed queryer issue with nested families
This commit is contained in:
@ -59,6 +59,17 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "get_counterparty_orders",
|
||||
"schemas": {
|
||||
"get_counterparty_orders.response": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "counterparty.order"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"enums": [],
|
||||
@ -734,6 +745,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"counterparty.order": {
|
||||
"type": "order",
|
||||
"properties": {
|
||||
"counterparty": {
|
||||
"family": "organization"
|
||||
}
|
||||
}
|
||||
},
|
||||
"light.order": {
|
||||
"type": "order",
|
||||
"properties": {
|
||||
@ -2332,6 +2351,92 @@
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Order select with nested polymorphic counterparty family relation",
|
||||
"action": "query",
|
||||
"schema_id": "get_counterparty_orders.response",
|
||||
"expect": {
|
||||
"success": true,
|
||||
"sql": [
|
||||
[
|
||||
"((SELECT jsonb_strip_nulls((",
|
||||
" SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'id', order_1.id,",
|
||||
" 'type', order_1.type,",
|
||||
" 'archived', entity_2.archived,",
|
||||
" 'created_at', entity_2.created_at,",
|
||||
" 'total', order_1.total,",
|
||||
" 'customer_id', order_1.customer_id,",
|
||||
" 'counterparty', (",
|
||||
" SELECT CASE",
|
||||
" WHEN organization_3.type = 'bot' THEN ((",
|
||||
" SELECT jsonb_build_object(",
|
||||
" 'id', entity_7.id,",
|
||||
" 'type', entity_7.type,",
|
||||
" 'archived', entity_7.archived,",
|
||||
" 'created_at', entity_7.created_at,",
|
||||
" 'name', organization_6.name,",
|
||||
" 'token', bot_5.token,",
|
||||
" 'role', bot_5.role",
|
||||
" )",
|
||||
" FROM agreego.bot bot_5",
|
||||
" JOIN agreego.organization organization_6 ON organization_6.id = bot_5.id",
|
||||
" JOIN agreego.entity entity_7 ON entity_7.id = organization_6.id",
|
||||
" WHERE",
|
||||
" NOT entity_7.archived",
|
||||
" AND entity_7.id = entity_4.id",
|
||||
" ))",
|
||||
" WHEN organization_3.type = 'organization' THEN ((",
|
||||
" SELECT jsonb_build_object(",
|
||||
" 'id', entity_9.id,",
|
||||
" 'type', entity_9.type,",
|
||||
" 'archived', entity_9.archived,",
|
||||
" 'created_at', entity_9.created_at,",
|
||||
" 'name', organization_8.name",
|
||||
" )",
|
||||
" FROM agreego.organization organization_8",
|
||||
" JOIN agreego.entity entity_9 ON entity_9.id = organization_8.id",
|
||||
" WHERE",
|
||||
" NOT entity_9.archived",
|
||||
" AND entity_9.id = entity_4.id",
|
||||
" ))",
|
||||
" WHEN organization_3.type = 'person' THEN ((",
|
||||
" SELECT jsonb_build_object(",
|
||||
" 'id', entity_12.id,",
|
||||
" 'type', entity_12.type,",
|
||||
" 'archived', entity_12.archived,",
|
||||
" 'created_at', entity_12.created_at,",
|
||||
" 'name', organization_11.name,",
|
||||
" 'first_name', person_10.first_name,",
|
||||
" 'last_name', person_10.last_name,",
|
||||
" 'age', person_10.age",
|
||||
" )",
|
||||
" FROM agreego.person person_10",
|
||||
" JOIN agreego.organization organization_11 ON organization_11.id = person_10.id",
|
||||
" JOIN agreego.entity entity_12 ON entity_12.id = organization_11.id",
|
||||
" WHERE",
|
||||
" NOT entity_12.archived",
|
||||
" AND entity_12.id = entity_4.id",
|
||||
" ))",
|
||||
" ELSE NULL",
|
||||
" END",
|
||||
" FROM agreego.organization organization_3",
|
||||
" JOIN agreego.entity entity_4 ON entity_4.id = organization_3.id",
|
||||
" WHERE",
|
||||
" NOT entity_4.archived",
|
||||
" AND order_1.counterparty_id = entity_4.id",
|
||||
" )",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.order order_1",
|
||||
" JOIN agreego.entity entity_2 ON entity_2.id = order_1.id",
|
||||
" WHERE",
|
||||
" NOT entity_2.archived",
|
||||
" AND order_1.counterparty_type = 'organization'",
|
||||
"))))"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user