lookup index validation: accept a type-scoped partial index on the hierarchy ancestor owning the key's columns
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@ -1111,5 +1111,147 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Validation - type-scoped lookup key enforced by a partial index on the hierarchy ancestor owning the column",
|
||||
"database": {
|
||||
"indexes": [
|
||||
{
|
||||
"table": "entity",
|
||||
"columns": ["name"],
|
||||
"predicate": "(type = 'registry'::text)"
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"id": "33333333-3333-3333-3333-333333333331",
|
||||
"type": "type",
|
||||
"name": "entity",
|
||||
"module": "test",
|
||||
"source": "test",
|
||||
"hierarchy": ["entity"],
|
||||
"variations": ["entity", "registry"],
|
||||
"fields": ["id", "type", "name"],
|
||||
"schemas": {
|
||||
"entity": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": { "type": "string", "format": "uuid" },
|
||||
"type": { "type": "string" },
|
||||
"name": { "type": "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "33333333-3333-3333-3333-333333333332",
|
||||
"type": "type",
|
||||
"name": "registry",
|
||||
"module": "test",
|
||||
"source": "test",
|
||||
"hierarchy": ["entity", "registry"],
|
||||
"variations": ["registry"],
|
||||
"fields": ["id", "type"],
|
||||
"lookup_fields": ["type", "name"],
|
||||
"schemas": {
|
||||
"registry": {
|
||||
"type": "entity",
|
||||
"properties": {
|
||||
"id": { "type": "string", "format": "uuid" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "Compiles successfully: the key's type component is covered by the index's partial predicate",
|
||||
"action": "compile",
|
||||
"expect": {
|
||||
"success": true,
|
||||
"schemas": {
|
||||
"entity": {},
|
||||
"entity.filter": {},
|
||||
"registry": {},
|
||||
"registry.filter": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Validation - type-scoped lookup key is NOT satisfied by an unscoped ancestor index",
|
||||
"database": {
|
||||
"indexes": [
|
||||
{
|
||||
"table": "entity",
|
||||
"columns": ["name"]
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"id": "44444444-4444-4444-4444-444444444441",
|
||||
"type": "type",
|
||||
"name": "entity",
|
||||
"module": "test",
|
||||
"source": "test",
|
||||
"hierarchy": ["entity"],
|
||||
"variations": ["entity", "registry"],
|
||||
"fields": ["id", "type", "name"],
|
||||
"schemas": {
|
||||
"entity": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": { "type": "string", "format": "uuid" },
|
||||
"type": { "type": "string" },
|
||||
"name": { "type": "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "44444444-4444-4444-4444-444444444442",
|
||||
"type": "type",
|
||||
"name": "registry",
|
||||
"module": "test",
|
||||
"source": "test",
|
||||
"hierarchy": ["entity", "registry"],
|
||||
"variations": ["registry"],
|
||||
"fields": ["id", "type"],
|
||||
"lookup_fields": ["type", "name"],
|
||||
"schemas": {
|
||||
"registry": {
|
||||
"type": "entity",
|
||||
"properties": {
|
||||
"id": { "type": "string", "format": "uuid" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "Fails with MISSING_LOOKUP_INDEX: a full entity(name) index does not carry the key's type scoping",
|
||||
"action": "compile",
|
||||
"expect": {
|
||||
"success": false,
|
||||
"errors": [
|
||||
{
|
||||
"code": "MISSING_LOOKUP_INDEX",
|
||||
"values": {
|
||||
"type": "registry",
|
||||
"lookup_fields": "[\"type\", \"name\"]"
|
||||
},
|
||||
"details": {
|
||||
"path": "/types/registry",
|
||||
"schema": "registry"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user