added jsonb field tests to queryer and merger and fixed a bug there

This commit is contained in:
2026-04-14 13:23:01 -04:00
parent 24adf3ffc6
commit 8984acaa5f
6 changed files with 2462 additions and 1993 deletions

View File

@ -826,6 +826,87 @@
"historical": true,
"notify": true,
"relationship": false
},
{
"name": "invoice",
"hierarchy": [
"invoice",
"entity"
],
"fields": [
"id",
"type",
"number",
"metadata",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
],
"grouped_fields": {
"invoice": [
"id",
"type",
"number",
"metadata"
],
"entity": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
]
},
"lookup_fields": [
"id"
],
"historical": true,
"relationship": false,
"field_types": {
"id": "uuid",
"type": "text",
"archived": "boolean",
"number": "text",
"metadata": "jsonb",
"created_at": "timestamptz",
"created_by": "uuid",
"modified_at": "timestamptz",
"modified_by": "uuid"
},
"schemas": {
"invoice": {
"type": "entity",
"properties": {
"id": {
"type": "string"
},
"number": {
"type": "string"
},
"metadata": {
"type": "object",
"properties": {
"internal_note": {
"type": "string"
},
"customer_snapshot": {
"type": "entity"
},
"related_rules": {
"type": "array",
"items": {
"type": "entity"
}
}
}
}
}
}
}
}
]
},
@ -2802,6 +2883,123 @@
]
]
}
},
{
"description": "Insert invoice with deep jsonb metadata",
"action": "merge",
"schema_id": "invoice",
"data": {
"id": "11111111-2222-3333-4444-555555555555",
"type": "invoice",
"number": "INV-1001",
"metadata": {
"internal_note": "Confidential",
"customer_snapshot": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "person",
"first_name": "John"
},
"related_rules": [
{
"id": "11111111-1111-1111-1111-111111111111",
"type": "entity"
}
]
}
},
"expect": {
"success": true,
"sql": [
[
"SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
"FROM agreego.\"invoice\" t1",
"LEFT JOIN agreego.\"entity\" t2 ON t2.id = t1.id",
"WHERE t1.id = '11111111-2222-3333-4444-555555555555' OR (\"id\" = '11111111-2222-3333-4444-555555555555')"
],
[
"INSERT INTO agreego.\"entity\" (",
" \"created_at\",",
" \"created_by\",",
" \"id\",",
" \"modified_at\",",
" \"modified_by\",",
" \"type\"",
")",
"VALUES (",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" '11111111-2222-3333-4444-555555555555',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" 'invoice'",
")"
],
[
"INSERT INTO agreego.\"invoice\" (",
" \"id\",",
" \"metadata\",",
" \"number\",",
" \"type\"",
")",
"VALUES (",
" '11111111-2222-3333-4444-555555555555',",
" '{",
" \"customer_snapshot\":{",
" \"first_name\":\"John\",",
" \"id\":\"00000000-0000-0000-0000-000000000000\",",
" \"type\":\"person\"",
" },",
" \"internal_note\":\"Confidential\",",
" \"related_rules\":[",
" {",
" \"id\":\"11111111-1111-1111-1111-111111111111\",",
" \"type\":\"entity\"",
" }",
" ]",
" }',",
" 'INV-1001',",
" 'invoice'",
")"
],
[
"INSERT INTO agreego.change (",
" \"old\",",
" \"new\",",
" entity_id,",
" id,",
" kind,",
" modified_at,",
" modified_by",
")",
"VALUES (",
" NULL,",
" '{",
" \"metadata\":{",
" \"customer_snapshot\":{",
" \"first_name\":\"John\",",
" \"id\":\"00000000-0000-0000-0000-000000000000\",",
" \"type\":\"person\"",
" },",
" \"internal_note\":\"Confidential\",",
" \"related_rules\":[",
" {",
" \"id\":\"11111111-1111-1111-1111-111111111111\",",
" \"type\":\"entity\"",
" }",
" ]",
" },",
" \"number\":\"INV-1001\",",
" \"type\":\"invoice\"",
" }',",
" '11111111-2222-3333-4444-555555555555',",
" '{{uuid}}',",
" 'create',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000'",
")"
]
]
}
}
]
}

File diff suppressed because it is too large Load Diff