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'",
|
||||
"))))"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use serde_json::Value;
|
||||
|
||||
pub fn compose(val: &mut Value, errors: &mut Vec<crate::drop::Error>) -> Result<(), String> {
|
||||
let _ = std::fs::write("/Users/awgneo/Repositories/thoughtpatterns/cellular/jspg/traits_debug_val.json", serde_json::to_string_pretty(val).unwrap());
|
||||
let mut traits = HashMap::new();
|
||||
let mut schemas = HashMap::new();
|
||||
|
||||
|
||||
@ -213,6 +213,7 @@ impl<'a> Compiler<'a> {
|
||||
|
||||
let mut case_node = node.clone();
|
||||
case_node.parent_alias = base_alias.clone();
|
||||
case_node.property_name = None;
|
||||
let arc_aliases = std::sync::Arc::new(table_aliases.clone());
|
||||
case_node.parent_type_aliases = Some(arc_aliases);
|
||||
case_node.parent_type = Some(r#type);
|
||||
|
||||
@ -1499,6 +1499,12 @@ fn test_queryer_0_14() {
|
||||
crate::tests::runner::run_test_case(&path, 0, 14).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_queryer_0_15() {
|
||||
let path = format!("{}/fixtures/queryer.json", env!("CARGO_MANIFEST_DIR"));
|
||||
crate::tests::runner::run_test_case(&path, 0, 15).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_polymorphism_0_0() {
|
||||
let path = format!("{}/fixtures/polymorphism.json", env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
Reference in New Issue
Block a user