added static property constraints using const and enums and fixed formatter ON rendering

This commit is contained in:
2026-07-09 14:47:39 -04:00
parent 1bb9586b9b
commit 942520a36a
3 changed files with 232 additions and 171 deletions

View File

@ -211,13 +211,6 @@
"gender": {}, "gender": {},
"gender.condition": { "gender.condition": {
"type": "condition", "type": "condition",
"compiledPropertyNames": [
"kind",
"$eq",
"$ne",
"$of",
"$nof"
],
"properties": { "properties": {
"$eq": { "$eq": {
"type": [ "type": [
@ -231,15 +224,6 @@
"null" "null"
] ]
}, },
"$nof": {
"type": [
"array",
"null"
],
"items": {
"type": "gender"
}
},
"$of": { "$of": {
"type": [ "type": [
"array", "array",
@ -248,149 +232,143 @@
"items": { "items": {
"type": "gender" "type": "gender"
} }
},
"$nof": {
"type": [
"array",
"null"
],
"items": {
"type": "gender"
} }
} }
}, },
"compiledPropertyNames": [
"kind",
"$eq",
"$ne",
"$of",
"$nof"
]
},
"person": {}, "person": {},
"person.filter": { "person.filter": {
"compiledPropertyNames": [ "type": "filter",
"first_name",
"age",
"billing_address",
"gender",
"birth_date",
"uuid_field",
"tags",
"ad_hoc",
"$and",
"$or"
],
"properties": { "properties": {
"$and": { "first_name": {
"items": {
"compiledPropertyNames": [
"first_name",
"age",
"billing_address",
"gender",
"birth_date",
"uuid_field",
"tags",
"ad_hoc",
"$and",
"$or"
],
"type": "person.filter"
},
"type": [
"array",
"null"
]
},
"$or": {
"items": {
"compiledPropertyNames": [
"first_name",
"age",
"billing_address",
"gender",
"birth_date",
"uuid_field",
"tags",
"ad_hoc",
"$and",
"$or"
],
"type": "person.filter"
},
"type": [
"array",
"null"
]
},
"ad_hoc": {
"compiledPropertyNames": [
"foo"
],
"properties": {
"foo": {
"type": [ "type": [
"string.condition", "string.condition",
"null" "null"
] ],
} "compiledPropertyNames": [
}, "kind",
"type": [ "$eq"
"filter",
"null"
] ]
}, },
"age": { "age": {
"type": [ "type": [
"integer.condition", "integer.condition",
"null" "null"
],
"compiledPropertyNames": [
"kind",
"$eq"
] ]
}, },
"billing_address": { "billing_address": {
"type": [ "type": [
"address.filter", "address.filter",
"null" "null"
] ],
}, "compiledPropertyNames": [
"birth_date": { "city",
"type": [ "$and",
"date.condition", "$or"
"null"
]
},
"uuid_field": {
"type": [
"uuid.condition",
"null"
]
},
"first_name": {
"type": [
"string.condition",
"null"
] ]
}, },
"gender": { "gender": {
"type": [ "type": [
"gender.condition", "gender.condition",
"null" "null"
],
"compiledPropertyNames": [
"kind",
"$eq",
"$ne",
"$of",
"$nof"
]
},
"birth_date": {
"type": [
"date.condition",
"null"
],
"compiledPropertyNames": [
"kind",
"$eq"
]
},
"uuid_field": {
"type": [
"uuid.condition",
"null"
],
"compiledPropertyNames": [
"kind",
"$eq"
] ]
}, },
"tags": { "tags": {
"type": [ "type": [
"string.condition", "string.condition",
"null" "null"
],
"compiledPropertyNames": [
"kind",
"$eq"
]
},
"ad_hoc": {
"type": [
"filter",
"null"
],
"properties": {
"foo": {
"type": [
"string.condition",
"null"
],
"compiledPropertyNames": [
"kind",
"$eq"
] ]
} }
}, },
"type": "filter"
},
"address": {},
"address.filter": {
"type": "filter",
"compiledPropertyNames": [ "compiledPropertyNames": [
"city", "foo"
"$and", ]
"$or" },
],
"properties": {
"$and": { "$and": {
"type": [ "type": [
"array", "array",
"null" "null"
], ],
"items": { "items": {
"type": "person.filter",
"compiledPropertyNames": [ "compiledPropertyNames": [
"city", "first_name",
"age",
"billing_address",
"gender",
"birth_date",
"uuid_field",
"tags",
"ad_hoc",
"$and", "$and",
"$or" "$or"
], ]
"type": "address.filter"
} }
}, },
"$or": { "$or": {
@ -399,22 +377,84 @@
"null" "null"
], ],
"items": { "items": {
"type": "person.filter",
"compiledPropertyNames": [ "compiledPropertyNames": [
"city", "first_name",
"age",
"billing_address",
"gender",
"birth_date",
"uuid_field",
"tags",
"ad_hoc",
"$and", "$and",
"$or" "$or"
], ]
"type": "address.filter" }
} }
}, },
"compiledPropertyNames": [
"first_name",
"age",
"billing_address",
"gender",
"birth_date",
"uuid_field",
"tags",
"ad_hoc",
"$and",
"$or"
]
},
"address": {},
"address.filter": {
"type": "filter",
"properties": {
"city": { "city": {
"type": [ "type": [
"string.condition", "string.condition",
"null" "null"
],
"compiledPropertyNames": [
"kind",
"$eq"
]
},
"$and": {
"type": [
"array",
"null"
],
"items": {
"type": "address.filter",
"compiledPropertyNames": [
"city",
"$and",
"$or"
]
}
},
"$or": {
"type": [
"array",
"null"
],
"items": {
"type": "address.filter",
"compiledPropertyNames": [
"city",
"$and",
"$or"
] ]
} }
} }
}, },
"compiledPropertyNames": [
"city",
"$and",
"$or"
]
},
"condition": {}, "condition": {},
"filter": {}, "filter": {},
"string.condition": {}, "string.condition": {},
@ -424,28 +464,47 @@
"search": {}, "search": {},
"search.filter": { "search.filter": {
"type": "filter", "type": "filter",
"properties": {
"kind": {
"type": [
"string.condition",
"null"
],
"compiledPropertyNames": [ "compiledPropertyNames": [
"kind", "kind",
"name", "$eq"
"filter", ]
"$and", },
"$or" "name": {
"type": [
"string.condition",
"null"
], ],
"properties": { "compiledPropertyNames": [
"kind",
"$eq"
]
},
"filter": {
"type": [
"$kind.filter",
"null"
]
},
"$and": { "$and": {
"type": [ "type": [
"array", "array",
"null" "null"
], ],
"items": { "items": {
"type": "search.filter",
"compiledPropertyNames": [ "compiledPropertyNames": [
"kind", "kind",
"name", "name",
"filter", "filter",
"$and", "$and",
"$or" "$or"
], ]
"type": "search.filter"
} }
}, },
"$or": { "$or": {
@ -454,35 +513,24 @@
"null" "null"
], ],
"items": { "items": {
"type": "search.filter",
"compiledPropertyNames": [ "compiledPropertyNames": [
"kind", "kind",
"name", "name",
"filter", "filter",
"$and", "$and",
"$or" "$or"
], ]
"type": "search.filter" }
} }
}, },
"filter": { "compiledPropertyNames": [
"type": [ "kind",
"$kind.filter", "name",
"null" "filter",
"$and",
"$or"
] ]
},
"kind": {
"type": [
"string.condition",
"null"
]
},
"name": {
"type": [
"string.condition",
"null"
]
}
}
} }
} }
} }

View File

@ -1,6 +1,6 @@
[ [
{ {
"description": "Queryer Execution", "description": "Queryer Suite 1",
"database": { "database": {
"puncs": [ "puncs": [
{ {
@ -2441,7 +2441,7 @@
] ]
}, },
{ {
"description": "Static relation constraints queries", "description": "Queryer Suite 2",
"database": { "database": {
"puncs": [ "puncs": [
{ {
@ -2671,6 +2671,7 @@
" WHERE", " WHERE",
" NOT entity_3.archived", " NOT entity_3.archived",
" AND attachment_4.kind = 'cover'", " AND attachment_4.kind = 'cover'",
" AND attachment_4.attachable_id = entity_1.id",
" ),", " ),",
" 'cover_attachments', (", " 'cover_attachments', (",
" SELECT COALESCE(jsonb_agg(jsonb_build_object(", " SELECT COALESCE(jsonb_agg(jsonb_build_object(",
@ -2683,6 +2684,7 @@
" WHERE", " WHERE",
" NOT entity_5.archived", " NOT entity_5.archived",
" AND attachment_6.kind = 'cover'", " AND attachment_6.kind = 'cover'",
" AND attachment_6.attachable_id = entity_1.id",
" ),", " ),",
" 'media_attachments', (", " 'media_attachments', (",
" SELECT COALESCE(jsonb_agg(jsonb_build_object(", " SELECT COALESCE(jsonb_agg(jsonb_build_object(",
@ -2695,6 +2697,7 @@
" WHERE", " WHERE",
" NOT entity_7.archived", " NOT entity_7.archived",
" AND attachment_8.kind IN ('cover', 'thumbnail')", " AND attachment_8.kind IN ('cover', 'thumbnail')",
" AND attachment_8.attachable_id = entity_1.id",
" )", " )",
" )", " )",
" FROM agreego.entity entity_1", " FROM agreego.entity entity_1",

View File

@ -40,6 +40,7 @@ impl Schema {
} }
let mut props = IndexMap::new(); let mut props = IndexMap::new();
let mut inherited_edges = IndexMap::new();
// 1. Resolve INHERITANCE dependencies first // 1. Resolve INHERITANCE dependencies first
if let Some(crate::database::object::SchemaTypeOrArray::Single(t)) = &self.obj.type_ { if let Some(crate::database::object::SchemaTypeOrArray::Single(t)) = &self.obj.type_ {
@ -49,6 +50,9 @@ impl Schema {
if let Some(p_props) = parent.obj.compiled_properties.get() { if let Some(p_props) = parent.obj.compiled_properties.get() {
props.extend(p_props.clone()); props.extend(p_props.clone());
} }
if let Some(p_edges) = parent.obj.compiled_edges.get() {
inherited_edges.extend(p_edges.clone());
}
} }
} }
} }
@ -80,6 +84,9 @@ impl Schema {
if let Some(p_props) = parent.obj.compiled_properties.get() { if let Some(p_props) = parent.obj.compiled_properties.get() {
props.extend(p_props.clone()); props.extend(p_props.clone());
} }
if let Some(p_edges) = parent.obj.compiled_edges.get() {
inherited_edges.extend(p_edges.clone());
}
} }
} }
} }
@ -119,7 +126,10 @@ impl Schema {
let _ = self.obj.compiled_property_names.set(names); let _ = self.obj.compiled_property_names.set(names);
// 5. Compute Edges natively // 5. Compute Edges natively
let schema_edges = self.compile_edges(db, root_id, &path, &props, errors); let mut schema_edges = self.compile_edges(db, root_id, &path, &props, errors);
for (k, v) in inherited_edges {
schema_edges.entry(k).or_insert(v);
}
let _ = self.obj.compiled_edges.set(schema_edges); let _ = self.obj.compiled_edges.set(schema_edges);
// 5. Build our inline children properties recursively NOW! (Depth-first search) // 5. Build our inline children properties recursively NOW! (Depth-first search)