beefed up schema compiled properties with cases properties and added tests with cases to queryer and merger
This commit is contained in:
@ -869,6 +869,106 @@
|
||||
"notify": true,
|
||||
"relationship": false
|
||||
},
|
||||
{
|
||||
"name": "account",
|
||||
"hierarchy": [
|
||||
"account",
|
||||
"entity"
|
||||
],
|
||||
"fields": [
|
||||
"id",
|
||||
"type",
|
||||
"name",
|
||||
"archived",
|
||||
"created_at",
|
||||
"created_by",
|
||||
"modified_at",
|
||||
"modified_by",
|
||||
"kind",
|
||||
"routing_number",
|
||||
"card_number"
|
||||
],
|
||||
"grouped_fields": {
|
||||
"entity": [
|
||||
"id",
|
||||
"type",
|
||||
"name",
|
||||
"archived",
|
||||
"created_at",
|
||||
"created_by",
|
||||
"modified_at",
|
||||
"modified_by"
|
||||
],
|
||||
"account": [
|
||||
"id",
|
||||
"type",
|
||||
"kind",
|
||||
"routing_number",
|
||||
"card_number"
|
||||
]
|
||||
},
|
||||
"field_types": {
|
||||
"id": "uuid",
|
||||
"type": "text",
|
||||
"archived": "boolean",
|
||||
"name": "text",
|
||||
"created_at": "timestamptz",
|
||||
"created_by": "uuid",
|
||||
"modified_at": "timestamptz",
|
||||
"modified_by": "uuid",
|
||||
"kind": "text",
|
||||
"routing_number": "text",
|
||||
"card_number": "text"
|
||||
},
|
||||
"schemas": {
|
||||
"account": {
|
||||
"type": "entity",
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"when": {
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "checking"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"routing_number": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "credit"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"card_number": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"lookup_fields": [],
|
||||
"historical": true,
|
||||
"notify": true,
|
||||
"relationship": false
|
||||
},
|
||||
{
|
||||
"name": "invoice",
|
||||
"schemas": {
|
||||
@ -3107,6 +3207,103 @@
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Insert account with checking kind and routing number",
|
||||
"action": "merge",
|
||||
"schema_id": "account",
|
||||
"data": {
|
||||
"id": "11111111-2222-3333-4444-555555555555",
|
||||
"type": "account",
|
||||
"kind": "checking",
|
||||
"routing_number": "123456789"
|
||||
},
|
||||
"expect": {
|
||||
"success": true,
|
||||
"sql": [
|
||||
[
|
||||
"SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
|
||||
"FROM agreego.\"account\" t1",
|
||||
"LEFT JOIN agreego.\"entity\" t2 ON t2.id = t1.id",
|
||||
"WHERE t1.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',",
|
||||
" 'account'",
|
||||
")"
|
||||
],
|
||||
[
|
||||
"INSERT INTO agreego.\"account\" (",
|
||||
" \"id\",",
|
||||
" \"kind\",",
|
||||
" \"routing_number\",",
|
||||
" \"type\"",
|
||||
")",
|
||||
"VALUES (",
|
||||
" '11111111-2222-3333-4444-555555555555',",
|
||||
" 'checking',",
|
||||
" '123456789',",
|
||||
" 'account'",
|
||||
")"
|
||||
],
|
||||
[
|
||||
"INSERT INTO agreego.change (",
|
||||
" \"old\",",
|
||||
" \"new\",",
|
||||
" entity_id,",
|
||||
" id,",
|
||||
" kind,",
|
||||
" modified_at,",
|
||||
" modified_by",
|
||||
")",
|
||||
"VALUES (",
|
||||
" NULL,",
|
||||
" '{",
|
||||
" \"kind\":\"checking\",",
|
||||
" \"routing_number\":\"123456789\",",
|
||||
" \"type\":\"account\"",
|
||||
" }',",
|
||||
" '11111111-2222-3333-4444-555555555555',",
|
||||
" '{{uuid}}',",
|
||||
" 'create',",
|
||||
" '{{timestamp}}',",
|
||||
" '00000000-0000-0000-0000-000000000000'",
|
||||
")"
|
||||
],
|
||||
[
|
||||
"SELECT pg_notify('entity', '{",
|
||||
" \"complete\":{",
|
||||
" \"created_at\":\"{{timestamp}}\",",
|
||||
" \"created_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||
" \"id\":\"11111111-2222-3333-4444-555555555555\",",
|
||||
" \"kind\":\"checking\",",
|
||||
" \"modified_at\":\"{{timestamp}}\",",
|
||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||
" \"routing_number\":\"123456789\",",
|
||||
" \"type\":\"account\"",
|
||||
" },",
|
||||
" \"new\":{",
|
||||
" \"kind\":\"checking\",",
|
||||
" \"routing_number\":\"123456789\",",
|
||||
" \"type\":\"account\"",
|
||||
" }",
|
||||
" }')"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user