fixed queryer relation issues

This commit is contained in:
2026-04-02 22:51:13 -04:00
parent 06f6a587de
commit 7876567ae7
9 changed files with 388 additions and 58 deletions

View File

@ -1,31 +1,62 @@
[
{
"description": "ambiguous M:M and missing boundaries",
"description": "Edge missing - 0 relations",
"database": {
"types": [
{ "name": "unrelated", "schema": {}, "is_enum": false, "parents": [], "variations": ["unrelated"], "has_table": true },
{ "name": "actor", "schema": {}, "is_enum": false, "parents": [], "variations": ["actor"], "has_table": true },
{ "name": "movie", "schema": {}, "is_enum": false, "parents": [], "variations": ["movie"], "has_table": true },
{ "name": "junction", "schema": {}, "is_enum": false, "parents": [], "variations": ["junction"], "has_table": true }
],
"relations": [
{ "constraint": "fk_junction_actor1", "source_type": "junction", "destination_type": "actor", "is_array": true, "prefix": null },
{ "constraint": "fk_junction_actor2", "source_type": "junction", "destination_type": "actor", "is_array": true, "prefix": null }
],
"schemas": [
{
"$id": "get.actor",
"properties": {
"missing_edge": { "$ref": "unrelated" },
"ambiguous_edge": { "$ref": "junction" }
}
"id": "11111111-1111-1111-1111-111111111111",
"type": "type",
"name": "org",
"module": "test",
"source": "test",
"hierarchy": [
"org"
],
"variations": [
"org"
],
"schemas": [
{
"$id": "full.org",
"type": "object",
"properties": {
"missing_users": {
"type": "array",
"items": {
"$ref": "full.user"
}
}
}
}
]
},
{
"id": "22222222-2222-2222-2222-222222222222",
"type": "type",
"name": "user",
"module": "test",
"source": "test",
"hierarchy": [
"user"
],
"variations": [
"user"
],
"schemas": [
{
"$id": "full.user",
"type": "object",
"properties": {}
}
]
}
]
],
"relations": []
},
"tests": [
{
"description": "throws EDGE_MISSING when relation does not exist",
"action": "database_compile",
"description": "throws EDGE_MISSING when 0 relations exist between org and user",
"action": "compile",
"expect": {
"success": false,
"errors": [
@ -34,10 +65,177 @@
}
]
}
},
}
]
},
{
"description": "Edge missing - array cardinality rejection",
"database": {
"types": [
{
"id": "11111111-1111-1111-1111-111111111111",
"type": "type",
"name": "parent",
"module": "test",
"source": "test",
"hierarchy": [
"parent"
],
"variations": [
"parent"
],
"schemas": [
{
"$id": "full.parent",
"type": "object",
"properties": {
"children": {
"type": "array",
"items": {
"$ref": "full.child"
}
}
}
}
]
},
{
"id": "22222222-2222-2222-2222-222222222222",
"type": "type",
"name": "child",
"module": "test",
"source": "test",
"hierarchy": [
"child"
],
"variations": [
"child"
],
"schemas": [
{
"$id": "full.child",
"type": "object",
"properties": {}
}
]
}
],
"relations": [
{
"id": "33333333-3333-3333-3333-333333333333",
"type": "relation",
"constraint": "fk_parent_child",
"source_type": "parent",
"source_columns": [
"child_id"
],
"destination_type": "child",
"destination_columns": [
"id"
]
}
]
},
"tests": [
{
"description": "throws AMBIGUOUS_TYPE_RELATIONS when junction has multi null prefixes",
"action": "database_compile",
"description": "throws EDGE_MISSING because a Forward scaler edge cannot mathematically fulfill an Array collection",
"action": "compile",
"expect": {
"success": false,
"errors": [
{
"code": "EDGE_MISSING"
}
]
}
}
]
},
{
"description": "Ambiguous type relations - multiple unprefixed relations",
"database": {
"types": [
{
"id": "11111111-1111-1111-1111-111111111111",
"type": "type",
"name": "invoice",
"module": "test",
"source": "test",
"hierarchy": [
"invoice"
],
"variations": [
"invoice"
],
"schemas": [
{
"$id": "full.invoice",
"type": "object",
"properties": {
"activities": {
"type": "array",
"items": {
"$ref": "full.activity"
}
}
}
}
]
},
{
"id": "22222222-2222-2222-2222-222222222222",
"type": "type",
"name": "activity",
"module": "test",
"source": "test",
"hierarchy": [
"activity"
],
"variations": [
"activity"
],
"schemas": [
{
"$id": "full.activity",
"type": "object",
"properties": {}
}
]
}
],
"relations": [
{
"id": "33333333-3333-3333-3333-333333333333",
"type": "relation",
"constraint": "fk_activity_invoice_1",
"source_type": "activity",
"source_columns": [
"invoice_id_1"
],
"destination_type": "invoice",
"destination_columns": [
"id"
]
},
{
"id": "44444444-4444-4444-4444-444444444444",
"type": "relation",
"constraint": "fk_activity_invoice_2",
"source_type": "activity",
"source_columns": [
"invoice_id_2"
],
"destination_type": "invoice",
"destination_columns": [
"id"
]
}
]
},
"tests": [
{
"description": "throws AMBIGUOUS_TYPE_RELATIONS when fallback encounters multiple naked constraints",
"action": "compile",
"expect": {
"success": false,
"errors": [
@ -50,30 +248,141 @@
]
},
{
"description": "invalid metadata identifiers",
"description": "Ambiguous type relations - M:M twin deduction failure",
"database": {
"types": [],
"relations": [],
"schemas": [
"types": [
{
"$id": "invalid@id",
"properties": {}
"id": "11111111-1111-1111-1111-111111111111",
"type": "type",
"name": "actor",
"module": "test",
"source": "test",
"hierarchy": [
"actor"
],
"variations": [
"actor"
],
"schemas": [
{
"$id": "full.actor",
"type": "object",
"properties": {
"ambiguous_edge": {
"type": "array",
"items": {
"$ref": "empty.junction"
}
}
}
}
]
},
{
"id": "22222222-2222-2222-2222-222222222222",
"type": "type",
"name": "junction",
"module": "test",
"source": "test",
"hierarchy": [
"junction"
],
"variations": [
"junction"
],
"schemas": [
{
"$id": "empty.junction",
"type": "object",
"properties": {}
}
]
}
],
"relations": [
{
"id": "33333333-3333-3333-3333-333333333333",
"type": "relation",
"constraint": "fk_junction_source_actor",
"source_type": "junction",
"source_columns": [
"source_id"
],
"destination_type": "actor",
"destination_columns": [
"id"
],
"prefix": "source"
},
{
"id": "44444444-4444-4444-4444-444444444444",
"type": "relation",
"constraint": "fk_junction_target_actor",
"source_type": "junction",
"source_columns": [
"target_id"
],
"destination_type": "actor",
"destination_columns": [
"id"
],
"prefix": "target"
}
]
},
"tests": [
{
"description": "throws INVALID_IDENTIFIER for non-alphanumeric ids",
"action": "database_compile",
"description": "throws AMBIGUOUS_TYPE_RELATIONS because child doesn't explicitly expose 'source' or 'target' for twin deduction",
"action": "compile",
"expect": {
"success": false,
"errors": [
{
"code": "INVALID_IDENTIFIER"
"code": "AMBIGUOUS_TYPE_RELATIONS"
}
]
}
}
]
},
{
"description": "Database type parse failed",
"database": {
"types": [
{
"id": [
"must",
"be",
"string",
"to",
"fail"
],
"type": "type",
"name": "failure",
"module": "test",
"source": "test",
"hierarchy": [
"failure"
],
"variations": [
"failure"
]
}
]
},
"tests": [
{
"description": "throws DATABASE_TYPE_PARSE_FAILED when metadata completely fails Serde typing",
"action": "compile",
"expect": {
"success": false,
"errors": [
{
"code": "DATABASE_TYPE_PARSE_FAILED"
}
]
}
}
]
}
]
]