fixed oneOf case queryer issue with resolving the table alias
This commit is contained in:
@ -1320,7 +1320,7 @@
|
||||
" 'id', entity_11.id,",
|
||||
" 'is_primary', contact_9.is_primary,",
|
||||
" 'target', CASE",
|
||||
" WHEN entity_11.target_type = 'address' THEN",
|
||||
" WHEN relationship_10.target_type = 'address' THEN",
|
||||
" ((SELECT jsonb_build_object(",
|
||||
" 'archived', entity_13.archived,",
|
||||
" 'city', address_12.city,",
|
||||
@ -1333,7 +1333,7 @@
|
||||
" WHERE",
|
||||
" NOT entity_13.archived",
|
||||
" AND relationship_10.target_id = entity_13.id))",
|
||||
" WHEN entity_11.target_type = 'email_address' THEN",
|
||||
" WHEN relationship_10.target_type = 'email_address' THEN",
|
||||
" ((SELECT jsonb_build_object(",
|
||||
" 'address', email_address_14.address,",
|
||||
" 'archived', entity_15.archived,",
|
||||
@ -1346,7 +1346,7 @@
|
||||
" WHERE",
|
||||
" NOT entity_15.archived",
|
||||
" AND relationship_10.target_id = entity_15.id))",
|
||||
" WHEN entity_11.target_type = 'phone_number' THEN",
|
||||
" WHEN relationship_10.target_type = 'phone_number' THEN",
|
||||
" ((SELECT jsonb_build_object(",
|
||||
" 'archived', entity_17.archived,",
|
||||
" 'created_at', entity_17.created_at,",
|
||||
@ -1556,7 +1556,7 @@
|
||||
" 'id', entity_11.id,",
|
||||
" 'is_primary', contact_9.is_primary,",
|
||||
" 'target', CASE",
|
||||
" WHEN entity_11.target_type = 'address' THEN",
|
||||
" WHEN relationship_10.target_type = 'address' THEN",
|
||||
" ((SELECT jsonb_build_object(",
|
||||
" 'archived', entity_13.archived,",
|
||||
" 'city', address_12.city,",
|
||||
@ -1569,7 +1569,7 @@
|
||||
" WHERE",
|
||||
" NOT entity_13.archived",
|
||||
" AND relationship_10.target_id = entity_13.id))",
|
||||
" WHEN entity_11.target_type = 'email_address' THEN",
|
||||
" WHEN relationship_10.target_type = 'email_address' THEN",
|
||||
" ((SELECT jsonb_build_object(",
|
||||
" 'address', email_address_14.address,",
|
||||
" 'archived', entity_15.archived,",
|
||||
@ -1582,7 +1582,7 @@
|
||||
" WHERE",
|
||||
" NOT entity_15.archived",
|
||||
" AND relationship_10.target_id = entity_15.id))",
|
||||
" WHEN entity_11.target_type = 'phone_number' THEN",
|
||||
" WHEN relationship_10.target_type = 'phone_number' THEN",
|
||||
" ((SELECT jsonb_build_object(",
|
||||
" 'archived', entity_17.archived,",
|
||||
" 'created_at', entity_17.created_at,",
|
||||
@ -1989,7 +1989,7 @@
|
||||
" 'is_primary', contact_11.is_primary,",
|
||||
" 'target',",
|
||||
" CASE",
|
||||
" WHEN entity_13.target_type = 'address' THEN (",
|
||||
" WHEN relationship_12.target_type = 'address' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_15.archived,",
|
||||
" 'city', address_14.city,",
|
||||
@ -2003,7 +2003,7 @@
|
||||
" NOT entity_15.archived",
|
||||
" AND relationship_12.target_id = entity_15.id)",
|
||||
" )",
|
||||
" WHEN entity_13.target_type = 'email_address' THEN (",
|
||||
" WHEN relationship_12.target_type = 'email_address' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'address', email_address_16.address,",
|
||||
" 'archived', entity_17.archived,",
|
||||
@ -2017,7 +2017,7 @@
|
||||
" NOT entity_17.archived",
|
||||
" AND relationship_12.target_id = entity_17.id)",
|
||||
" )",
|
||||
" WHEN entity_13.target_type = 'phone_number' THEN (",
|
||||
" WHEN relationship_12.target_type = 'phone_number' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_19.archived,",
|
||||
" 'created_at', entity_19.created_at,",
|
||||
|
||||
@ -461,10 +461,24 @@ impl<'a> Compiler<'a> {
|
||||
.cloned()
|
||||
.unwrap_or_else(|| format!("{}_t_err", node.parent_alias));
|
||||
|
||||
let mut lookup_key = prop_key.as_str();
|
||||
|
||||
if let Some(edges) = node.schema.obj.compiled_edges.get() {
|
||||
if let Some(edge) = edges.get(prop_key) {
|
||||
if let Some(relation) = self.db.relations.get(&edge.constraint) {
|
||||
if edge.forward {
|
||||
lookup_key = &relation.source_columns[0];
|
||||
} else {
|
||||
lookup_key = &relation.destination_columns[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(gf) = grouped_fields {
|
||||
for (t_name, fields_val) in gf {
|
||||
if let Some(fields_arr) = fields_val.as_array() {
|
||||
if fields_arr.iter().any(|v| v.as_str() == Some(prop_key)) {
|
||||
if fields_arr.iter().any(|v| v.as_str() == Some(lookup_key)) {
|
||||
owner_alias = table_aliases
|
||||
.get(t_name)
|
||||
.cloned()
|
||||
|
||||
27
test_out.txt
Normal file
27
test_out.txt
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user