Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ba5079fb73 | |||
| 98e7f5da12 | |||
| 9599b4cbc3 | |||
| f51799f0b1 | |||
| c8757e1709 |
@ -138,6 +138,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"filter": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"condition": {
|
"condition": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -300,7 +303,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"type": [
|
"type": [
|
||||||
"object",
|
"filter",
|
||||||
"null"
|
"null"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -341,11 +344,11 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"type": "object"
|
"type": "filter"
|
||||||
},
|
},
|
||||||
"address": {},
|
"address": {},
|
||||||
"address.filter": {
|
"address.filter": {
|
||||||
"type": "object",
|
"type": "filter",
|
||||||
"compiledPropertyNames": [
|
"compiledPropertyNames": [
|
||||||
"$and",
|
"$and",
|
||||||
"$or",
|
"$or",
|
||||||
@ -389,12 +392,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"condition": {},
|
"condition": {},
|
||||||
|
"filter": {},
|
||||||
"string.condition": {},
|
"string.condition": {},
|
||||||
"integer.condition": {},
|
"integer.condition": {},
|
||||||
"date.condition": {},
|
"date.condition": {},
|
||||||
"search": {},
|
"search": {},
|
||||||
"search.filter": {
|
"search.filter": {
|
||||||
"type": "object",
|
"type": "filter",
|
||||||
"compiledPropertyNames": [
|
"compiledPropertyNames": [
|
||||||
"$and",
|
"$and",
|
||||||
"$or",
|
"$or",
|
||||||
|
|||||||
@ -1320,7 +1320,7 @@
|
|||||||
" 'id', entity_11.id,",
|
" 'id', entity_11.id,",
|
||||||
" 'is_primary', contact_9.is_primary,",
|
" 'is_primary', contact_9.is_primary,",
|
||||||
" 'target', CASE",
|
" 'target', CASE",
|
||||||
" WHEN entity_11.target_type = 'address' THEN",
|
" WHEN relationship_10.target_type = 'address' THEN",
|
||||||
" ((SELECT jsonb_build_object(",
|
" ((SELECT jsonb_build_object(",
|
||||||
" 'archived', entity_13.archived,",
|
" 'archived', entity_13.archived,",
|
||||||
" 'city', address_12.city,",
|
" 'city', address_12.city,",
|
||||||
@ -1333,7 +1333,7 @@
|
|||||||
" WHERE",
|
" WHERE",
|
||||||
" NOT entity_13.archived",
|
" NOT entity_13.archived",
|
||||||
" AND relationship_10.target_id = entity_13.id))",
|
" 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(",
|
" ((SELECT jsonb_build_object(",
|
||||||
" 'address', email_address_14.address,",
|
" 'address', email_address_14.address,",
|
||||||
" 'archived', entity_15.archived,",
|
" 'archived', entity_15.archived,",
|
||||||
@ -1346,7 +1346,7 @@
|
|||||||
" WHERE",
|
" WHERE",
|
||||||
" NOT entity_15.archived",
|
" NOT entity_15.archived",
|
||||||
" AND relationship_10.target_id = entity_15.id))",
|
" 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(",
|
" ((SELECT jsonb_build_object(",
|
||||||
" 'archived', entity_17.archived,",
|
" 'archived', entity_17.archived,",
|
||||||
" 'created_at', entity_17.created_at,",
|
" 'created_at', entity_17.created_at,",
|
||||||
@ -1556,7 +1556,7 @@
|
|||||||
" 'id', entity_11.id,",
|
" 'id', entity_11.id,",
|
||||||
" 'is_primary', contact_9.is_primary,",
|
" 'is_primary', contact_9.is_primary,",
|
||||||
" 'target', CASE",
|
" 'target', CASE",
|
||||||
" WHEN entity_11.target_type = 'address' THEN",
|
" WHEN relationship_10.target_type = 'address' THEN",
|
||||||
" ((SELECT jsonb_build_object(",
|
" ((SELECT jsonb_build_object(",
|
||||||
" 'archived', entity_13.archived,",
|
" 'archived', entity_13.archived,",
|
||||||
" 'city', address_12.city,",
|
" 'city', address_12.city,",
|
||||||
@ -1569,7 +1569,7 @@
|
|||||||
" WHERE",
|
" WHERE",
|
||||||
" NOT entity_13.archived",
|
" NOT entity_13.archived",
|
||||||
" AND relationship_10.target_id = entity_13.id))",
|
" 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(",
|
" ((SELECT jsonb_build_object(",
|
||||||
" 'address', email_address_14.address,",
|
" 'address', email_address_14.address,",
|
||||||
" 'archived', entity_15.archived,",
|
" 'archived', entity_15.archived,",
|
||||||
@ -1582,7 +1582,7 @@
|
|||||||
" WHERE",
|
" WHERE",
|
||||||
" NOT entity_15.archived",
|
" NOT entity_15.archived",
|
||||||
" AND relationship_10.target_id = entity_15.id))",
|
" 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(",
|
" ((SELECT jsonb_build_object(",
|
||||||
" 'archived', entity_17.archived,",
|
" 'archived', entity_17.archived,",
|
||||||
" 'created_at', entity_17.created_at,",
|
" 'created_at', entity_17.created_at,",
|
||||||
@ -1989,7 +1989,7 @@
|
|||||||
" 'is_primary', contact_11.is_primary,",
|
" 'is_primary', contact_11.is_primary,",
|
||||||
" 'target',",
|
" 'target',",
|
||||||
" CASE",
|
" CASE",
|
||||||
" WHEN entity_13.target_type = 'address' THEN (",
|
" WHEN relationship_12.target_type = 'address' THEN (",
|
||||||
" (SELECT jsonb_build_object(",
|
" (SELECT jsonb_build_object(",
|
||||||
" 'archived', entity_15.archived,",
|
" 'archived', entity_15.archived,",
|
||||||
" 'city', address_14.city,",
|
" 'city', address_14.city,",
|
||||||
@ -2003,7 +2003,7 @@
|
|||||||
" NOT entity_15.archived",
|
" NOT entity_15.archived",
|
||||||
" AND relationship_12.target_id = entity_15.id)",
|
" 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(",
|
" (SELECT jsonb_build_object(",
|
||||||
" 'address', email_address_16.address,",
|
" 'address', email_address_16.address,",
|
||||||
" 'archived', entity_17.archived,",
|
" 'archived', entity_17.archived,",
|
||||||
@ -2017,7 +2017,7 @@
|
|||||||
" NOT entity_17.archived",
|
" NOT entity_17.archived",
|
||||||
" AND relationship_12.target_id = entity_17.id)",
|
" 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(",
|
" (SELECT jsonb_build_object(",
|
||||||
" 'archived', entity_19.archived,",
|
" 'archived', entity_19.archived,",
|
||||||
" 'created_at', entity_19.created_at,",
|
" 'created_at', entity_19.created_at,",
|
||||||
|
|||||||
@ -34,7 +34,7 @@ impl Schema {
|
|||||||
|
|
||||||
if let Some(mut inline_schema) = structural_filter {
|
if let Some(mut inline_schema) = structural_filter {
|
||||||
inline_schema.obj.type_ = Some(SchemaTypeOrArray::Multiple(vec![
|
inline_schema.obj.type_ = Some(SchemaTypeOrArray::Multiple(vec![
|
||||||
"object".to_string(),
|
"filter".to_string(),
|
||||||
"null".to_string(),
|
"null".to_string(),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
@ -104,8 +104,8 @@ impl Schema {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut wrapper_obj = SchemaObject::default();
|
let mut wrapper_obj = SchemaObject::default();
|
||||||
// Filters are just plain objects containing conditions, no inheritance required
|
// Filters now inherit from the base 'filter' type
|
||||||
wrapper_obj.type_ = Some(SchemaTypeOrArray::Single("object".to_string()));
|
wrapper_obj.type_ = Some(SchemaTypeOrArray::Single("filter".to_string()));
|
||||||
wrapper_obj.properties = Some(filter_props);
|
wrapper_obj.properties = Some(filter_props);
|
||||||
|
|
||||||
return Some(Schema {
|
return Some(Schema {
|
||||||
|
|||||||
@ -461,10 +461,24 @@ impl<'a> Compiler<'a> {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_else(|| format!("{}_t_err", node.parent_alias));
|
.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 {
|
if let Some(gf) = grouped_fields {
|
||||||
for (t_name, fields_val) in gf {
|
for (t_name, fields_val) in gf {
|
||||||
if let Some(fields_arr) = fields_val.as_array() {
|
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
|
owner_alias = table_aliases
|
||||||
.get(t_name)
|
.get(t_name)
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|||||||
@ -160,7 +160,7 @@ fn test_library_api() {
|
|||||||
"target": { "type": ["target_schema.filter", "null"] },
|
"target": { "type": ["target_schema.filter", "null"] },
|
||||||
"type": { "type": ["string.condition", "null"] }
|
"type": { "type": ["string.condition", "null"] }
|
||||||
},
|
},
|
||||||
"type": "object"
|
"type": "filter"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sensitive": false,
|
"sensitive": false,
|
||||||
@ -211,7 +211,7 @@ fn test_library_api() {
|
|||||||
},
|
},
|
||||||
"value": { "type": ["number.condition", "null"] }
|
"value": { "type": ["number.condition", "null"] }
|
||||||
},
|
},
|
||||||
"type": "object"
|
"type": "filter"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sensitive": false,
|
"sensitive": false,
|
||||||
|
|||||||
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