more executor reverts

This commit is contained in:
2026-06-11 17:37:34 -04:00
parent 7e28eb2645
commit 813e9ff3c2
5 changed files with 120 additions and 164 deletions

View File

@ -1242,8 +1242,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -1256,12 +1255,12 @@
" '{{uuid:generated_1}}',", " '{{uuid:generated_1}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'person'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"first_name\": \"IncompleteFirst\",", " \"first_name\": \"IncompleteFirst\",",
" \"last_name\": \"IncompleteLast\",", " \"last_name\": \"IncompleteLast\",",
@ -1276,8 +1275,7 @@
" \"first_name\": \"IncompleteFirst\",", " \"first_name\": \"IncompleteFirst\",",
" \"last_name\": \"IncompleteLast\",", " \"last_name\": \"IncompleteLast\",",
" \"type\": \"person\"", " \"type\": \"person\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]
@ -1342,8 +1340,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" '{", " '{",
@ -1357,12 +1354,12 @@
" '{{uuid:generated_0}}',", " '{{uuid:generated_0}}',",
" 'update',", " 'update',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'person'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"update\",",
" \"complete\": {", " \"complete\": {",
" \"id\": \"{{uuid:mocks.0.id}}\",", " \"id\": \"{{uuid:mocks.0.id}}\",",
" \"type\": \"person\",", " \"type\": \"person\",",
@ -1378,7 +1375,6 @@
" \"contact_id\": \"abc-contact\",", " \"contact_id\": \"abc-contact\",",
" \"type\": \"person\"", " \"type\": \"person\"",
" },", " },",
" \"kind\": \"update\",",
" \"old\": {", " \"old\": {",
" \"contact_id\": \"old-contact\"", " \"contact_id\": \"old-contact\"",
" }", " }",
@ -1448,8 +1444,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" '{", " '{",
@ -1463,12 +1458,12 @@
" '{{uuid:generated_0}}',", " '{{uuid:generated_0}}',",
" 'update',", " 'update',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'person'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"update\",",
" \"complete\": {", " \"complete\": {",
" \"id\": \"{{uuid:mocks.0.id}}\",", " \"id\": \"{{uuid:mocks.0.id}}\",",
" \"type\": \"person\",", " \"type\": \"person\",",
@ -1484,7 +1479,6 @@
" \"contact_id\": \"abc-contact\",", " \"contact_id\": \"abc-contact\",",
" \"type\": \"person\"", " \"type\": \"person\"",
" },", " },",
" \"kind\": \"update\",",
" \"old\": {", " \"old\": {",
" \"contact_id\": \"old-contact\"", " \"contact_id\": \"old-contact\"",
" },", " },",
@ -1535,6 +1529,7 @@
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"replace\",",
" \"complete\": {", " \"complete\": {",
" \"id\": \"{{uuid:mocks.0.id}}\",", " \"id\": \"{{uuid:mocks.0.id}}\",",
" \"type\": \"person\",", " \"type\": \"person\",",
@ -1549,7 +1544,6 @@
" \"new\": {", " \"new\": {",
" \"type\": \"person\"", " \"type\": \"person\"",
" },", " },",
" \"kind\": \"replace\",",
" \"replaces\": \"{{uuid:data.id}}\"", " \"replaces\": \"{{uuid:data.id}}\"",
"}'))" "}'))"
] ]
@ -1608,8 +1602,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" '{", " '{",
@ -1625,12 +1618,12 @@
" '{{uuid:generated_0}}',", " '{{uuid:generated_0}}',",
" 'update',", " 'update',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'person'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"update\",",
" \"complete\": {", " \"complete\": {",
" \"id\": \"{{uuid:mocks.0.id}}\",", " \"id\": \"{{uuid:mocks.0.id}}\",",
" \"type\": \"person\",", " \"type\": \"person\",",
@ -1644,7 +1637,6 @@
" \"last_name\": \"NewLast\",", " \"last_name\": \"NewLast\",",
" \"type\": \"person\"", " \"type\": \"person\"",
" },", " },",
" \"kind\": \"update\",",
" \"old\": {", " \"old\": {",
" \"first_name\": \"OldFirst\",", " \"first_name\": \"OldFirst\",",
" \"last_name\": \"OldLast\"", " \"last_name\": \"OldLast\"",
@ -1742,8 +1734,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -1758,12 +1749,12 @@
" '{{uuid:generated_0}}',", " '{{uuid:generated_0}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'person'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"first_name\": \"John\",", " \"first_name\": \"John\",",
" \"last_name\": \"Doe\",", " \"last_name\": \"Doe\",",
@ -1782,8 +1773,7 @@
" \"date_of_birth\": \"{{timestamp}}\",", " \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"\",", " \"pronouns\": \"\",",
" \"type\": \"person\"", " \"type\": \"person\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]
@ -1870,8 +1860,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -1886,8 +1875,7 @@
" '{{uuid:generated_2}}',", " '{{uuid:generated_2}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'person'",
")" ")"
], ],
[ [
@ -1930,8 +1918,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -1944,12 +1931,12 @@
" '{{uuid:generated_4}}',", " '{{uuid:generated_4}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'order'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"total\": 100.0,", " \"total\": 100.0,",
" \"id\": \"{{uuid:generated_3}}\",", " \"id\": \"{{uuid:generated_3}}\",",
@ -1964,12 +1951,12 @@
" \"total\": 100.0,", " \"total\": 100.0,",
" \"type\": \"order\",", " \"type\": \"order\",",
" \"customer_id\": \"{{uuid:generated_0}}\"", " \"customer_id\": \"{{uuid:generated_0}}\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"first_name\": \"Bob\",", " \"first_name\": \"Bob\",",
" \"last_name\": \"Smith\",", " \"last_name\": \"Smith\",",
@ -1988,8 +1975,7 @@
" \"date_of_birth\": \"2000-01-01\",", " \"date_of_birth\": \"2000-01-01\",",
" \"type\": \"person\",", " \"type\": \"person\",",
" \"organization_id\": \"{{uuid:generated_1}}\"", " \"organization_id\": \"{{uuid:generated_1}}\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]
@ -2094,8 +2080,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2109,8 +2094,7 @@
" '{{uuid:generated_1}}',", " '{{uuid:generated_1}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'order_line'",
")" ")"
], ],
[ [
@ -2121,8 +2105,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2134,12 +2117,12 @@
" '{{uuid:generated_2}}',", " '{{uuid:generated_2}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'order'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"total\": 99.0,", " \"total\": 99.0,",
" \"id\": \"abc\",", " \"id\": \"abc\",",
@ -2152,12 +2135,12 @@
" \"new\": {", " \"new\": {",
" \"total\": 99.0,", " \"total\": 99.0,",
" \"type\": \"order\"", " \"type\": \"order\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"product\": \"Widget\",", " \"product\": \"Widget\",",
" \"price\": 99.0,", " \"price\": 99.0,",
@ -2174,8 +2157,7 @@
" \"price\": 99.0,", " \"price\": 99.0,",
" \"order_id\": \"abc\",", " \"order_id\": \"abc\",",
" \"type\": \"order_line\"", " \"type\": \"order_line\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]
@ -2307,8 +2289,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2320,8 +2301,7 @@
" '{{uuid:generated_2}}',", " '{{uuid:generated_2}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'phone_number'",
")" ")"
], ],
[ [
@ -2372,8 +2352,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2389,8 +2368,7 @@
" '{{uuid:generated_4}}',", " '{{uuid:generated_4}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'contact'",
")" ")"
], ],
[ [
@ -2427,8 +2405,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2440,8 +2417,7 @@
" '{{uuid:generated_6}}',", " '{{uuid:generated_6}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'email_address'",
")" ")"
], ],
[ [
@ -2492,8 +2468,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2509,8 +2484,7 @@
" '{{uuid:generated_8}}',", " '{{uuid:generated_8}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'contact'",
")" ")"
], ],
[ [
@ -2547,8 +2521,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2560,8 +2533,7 @@
" '{{uuid:generated_10}}',", " '{{uuid:generated_10}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'email_address'",
")" ")"
], ],
[ [
@ -2612,8 +2584,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2629,8 +2600,7 @@
" '{{uuid:generated_12}}',", " '{{uuid:generated_12}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'contact'",
")" ")"
], ],
[ [
@ -2641,8 +2611,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2655,12 +2624,12 @@
" '{{uuid:generated_13}}',", " '{{uuid:generated_13}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'person'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"first_name\": \"Relation\",", " \"first_name\": \"Relation\",",
" \"last_name\": \"Test\",", " \"last_name\": \"Test\",",
@ -2675,12 +2644,12 @@
" \"first_name\": \"Relation\",", " \"first_name\": \"Relation\",",
" \"last_name\": \"Test\",", " \"last_name\": \"Test\",",
" \"type\": \"person\"", " \"type\": \"person\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"is_primary\": true,", " \"is_primary\": true,",
" \"source_id\": \"{{uuid:generated_0}}\",", " \"source_id\": \"{{uuid:generated_0}}\",",
@ -2701,12 +2670,12 @@
" \"target_id\": \"{{uuid:generated_1}}\",", " \"target_id\": \"{{uuid:generated_1}}\",",
" \"target_type\": \"phone_number\",", " \"target_type\": \"phone_number\",",
" \"type\": \"contact\"", " \"type\": \"contact\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"number\": \"555-0001\",", " \"number\": \"555-0001\",",
" \"id\": \"{{uuid:generated_1}}\",", " \"id\": \"{{uuid:generated_1}}\",",
@ -2719,12 +2688,12 @@
" \"new\": {", " \"new\": {",
" \"number\": \"555-0001\",", " \"number\": \"555-0001\",",
" \"type\": \"phone_number\"", " \"type\": \"phone_number\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"is_primary\": false,", " \"is_primary\": false,",
" \"source_id\": \"{{uuid:generated_0}}\",", " \"source_id\": \"{{uuid:generated_0}}\",",
@ -2745,12 +2714,12 @@
" \"target_id\": \"{{uuid:generated_5}}\",", " \"target_id\": \"{{uuid:generated_5}}\",",
" \"target_type\": \"email_address\",", " \"target_type\": \"email_address\",",
" \"type\": \"contact\"", " \"type\": \"contact\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"address\": \"test@example.com\",", " \"address\": \"test@example.com\",",
" \"id\": \"{{uuid:generated_5}}\",", " \"id\": \"{{uuid:generated_5}}\",",
@ -2763,12 +2732,12 @@
" \"new\": {", " \"new\": {",
" \"address\": \"test@example.com\",", " \"address\": \"test@example.com\",",
" \"type\": \"email_address\"", " \"type\": \"email_address\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"is_primary\": false,", " \"is_primary\": false,",
" \"source_id\": \"{{uuid:generated_0}}\",", " \"source_id\": \"{{uuid:generated_0}}\",",
@ -2789,12 +2758,12 @@
" \"target_id\": \"{{uuid:generated_9}}\",", " \"target_id\": \"{{uuid:generated_9}}\",",
" \"target_type\": \"email_address\",", " \"target_type\": \"email_address\",",
" \"type\": \"contact\"", " \"type\": \"contact\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"address\": \"test2@example.com\",", " \"address\": \"test2@example.com\",",
" \"id\": \"{{uuid:generated_9}}\",", " \"id\": \"{{uuid:generated_9}}\",",
@ -2807,8 +2776,7 @@
" \"new\": {", " \"new\": {",
" \"address\": \"test2@example.com\",", " \"address\": \"test2@example.com\",",
" \"type\": \"email_address\"", " \"type\": \"email_address\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]
@ -2860,8 +2828,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" '{", " '{",
@ -2875,12 +2842,12 @@
" '{{uuid:generated_0}}',", " '{{uuid:generated_0}}',",
" 'delete',", " 'delete',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'person'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"delete\",",
" \"complete\": {", " \"complete\": {",
" \"id\": \"abc-archived\",", " \"id\": \"abc-archived\",",
" \"type\": \"person\",", " \"type\": \"person\",",
@ -2894,7 +2861,6 @@
" \"archived\": true,", " \"archived\": true,",
" \"type\": \"person\"", " \"type\": \"person\"",
" },", " },",
" \"kind\": \"delete\",",
" \"old\": {", " \"old\": {",
" \"archived\": false", " \"archived\": false",
" }", " }",
@ -2969,8 +2935,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -2991,12 +2956,12 @@
" '{{uuid:generated_1}}',", " '{{uuid:generated_1}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'attachment'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"flags\": [", " \"flags\": [",
" \"urgent\",", " \"urgent\",",
@ -3027,8 +2992,7 @@
" \"type\": \"type_metadata\"", " \"type\": \"type_metadata\"",
" },", " },",
" \"type\": \"attachment\"", " \"type\": \"attachment\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]
@ -3094,8 +3058,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -3109,12 +3072,12 @@
" '{{uuid:generated_1}}',", " '{{uuid:generated_1}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'order_line'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"product\": \"Widget\",", " \"product\": \"Widget\",",
" \"price\": 99.0,", " \"price\": 99.0,",
@ -3131,8 +3094,7 @@
" \"price\": 99.0,", " \"price\": 99.0,",
" \"order_id\": \"abc\",", " \"order_id\": \"abc\",",
" \"type\": \"order_line\"", " \"type\": \"order_line\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]
@ -3206,8 +3168,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -3221,12 +3182,12 @@
" '{{uuid:generated_0}}',", " '{{uuid:generated_0}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'order_line'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"product\": \"Widget\",", " \"product\": \"Widget\",",
" \"price\": 99.0,", " \"price\": 99.0,",
@ -3243,8 +3204,7 @@
" \"price\": 99.0,", " \"price\": 99.0,",
" \"order_id\": \"abc\",", " \"order_id\": \"abc\",",
" \"type\": \"order_line\"", " \"type\": \"order_line\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]
@ -3349,8 +3309,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -3382,8 +3341,7 @@
" '{{uuid:generated_0}}',", " '{{uuid:generated_0}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'invoice'",
")" ")"
] ]
] ]
@ -3449,8 +3407,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -3463,12 +3420,12 @@
" '{{uuid:generated_0}}',", " '{{uuid:generated_0}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'account'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"kind\": \"checking\",", " \"kind\": \"checking\",",
" \"routing_number\": \"123456789\",", " \"routing_number\": \"123456789\",",
@ -3483,8 +3440,7 @@
" \"kind\": \"checking\",", " \"kind\": \"checking\",",
" \"routing_number\": \"123456789\",", " \"routing_number\": \"123456789\",",
" \"type\": \"account\"", " \"type\": \"account\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]
@ -3577,8 +3533,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -3592,8 +3547,7 @@
" '{{uuid:generated_2}}',", " '{{uuid:generated_2}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'person'",
")" ")"
], ],
[ [
@ -3668,8 +3622,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -3682,8 +3635,7 @@
" '{{uuid:generated_5}}',", " '{{uuid:generated_5}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'order_line'",
")" ")"
], ],
[ [
@ -3726,8 +3678,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -3740,8 +3691,7 @@
" '{{uuid:generated_7}}',", " '{{uuid:generated_7}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'order_line'",
")" ")"
], ],
[ [
@ -3752,8 +3702,7 @@
" \"id\",", " \"id\",",
" \"kind\",", " \"kind\",",
" \"modified_at\",", " \"modified_at\",",
" \"modified_by\",", " \"modified_by\"",
" \"entity_type\"",
")", ")",
"VALUES (", "VALUES (",
" NULL,", " NULL,",
@ -3766,12 +3715,12 @@
" '{{uuid:generated_8}}',", " '{{uuid:generated_8}}',",
" 'create',", " 'create',",
" '{{timestamp}}',", " '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',", " '00000000-0000-0000-0000-000000000000'",
" 'order'",
")" ")"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"organization_id\": \"parent-org-id\",", " \"organization_id\": \"parent-org-id\",",
" \"id\": \"{{uuid:generated_3}}\",", " \"id\": \"{{uuid:generated_3}}\",",
@ -3786,12 +3735,12 @@
" \"organization_id\": \"parent-org-id\",", " \"organization_id\": \"parent-org-id\",",
" \"type\": \"order\",", " \"type\": \"order\",",
" \"customer_id\": \"{{uuid:generated_0}}\"", " \"customer_id\": \"{{uuid:generated_0}}\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"first_name\": \"Const\",", " \"first_name\": \"Const\",",
" \"last_name\": \"Person\",", " \"last_name\": \"Person\",",
@ -3808,12 +3757,12 @@
" \"last_name\": \"Person\",", " \"last_name\": \"Person\",",
" \"type\": \"person\",", " \"type\": \"person\",",
" \"organization_id\": \"{{uuid:generated_1}}\"", " \"organization_id\": \"{{uuid:generated_1}}\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"order_id\": \"{{uuid:generated_3}}\",", " \"order_id\": \"{{uuid:generated_3}}\",",
" \"id\": \"{{uuid:generated_4}}\",", " \"id\": \"{{uuid:generated_4}}\",",
@ -3828,12 +3777,12 @@
" \"order_id\": \"{{uuid:generated_3}}\",", " \"order_id\": \"{{uuid:generated_3}}\",",
" \"type\": \"order_line\",", " \"type\": \"order_line\",",
" \"organization_id\": \"parent-org-id\"", " \"organization_id\": \"parent-org-id\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
], ],
[ [
"(SELECT pg_notify('entity', '{", "(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {", " \"complete\": {",
" \"organization_id\": \"explicit-org-id\",", " \"organization_id\": \"explicit-org-id\",",
" \"order_id\": \"{{uuid:generated_3}}\",", " \"order_id\": \"{{uuid:generated_3}}\",",
@ -3848,8 +3797,7 @@
" \"organization_id\": \"explicit-org-id\",", " \"organization_id\": \"explicit-org-id\",",
" \"order_id\": \"{{uuid:generated_3}}\",", " \"order_id\": \"{{uuid:generated_3}}\",",
" \"type\": \"order_line\"", " \"type\": \"order_line\"",
" },", " }",
" \"kind\": \"create\"",
"}'))" "}'))"
] ]
] ]

View File

@ -85,7 +85,6 @@ impl DatabaseExecutor for MockExecutor {
Ok("2026-03-10T00:00:00Z".to_string()) Ok("2026-03-10T00:00:00Z".to_string())
} }
#[cfg(test)] #[cfg(test)]
fn get_queries(&self) -> Vec<String> { fn get_queries(&self) -> Vec<String> {
MOCK_STATE.with(|state| state.borrow().captured_queries.clone()) MOCK_STATE.with(|state| state.borrow().captured_queries.clone())

View File

@ -20,7 +20,6 @@ pub trait DatabaseExecutor: Send + Sync {
/// Returns the current transaction timestamp /// Returns the current transaction timestamp
fn timestamp(&self) -> Result<String, String>; fn timestamp(&self) -> Result<String, String>;
#[cfg(test)] #[cfg(test)]
fn get_queries(&self) -> Vec<String>; fn get_queries(&self) -> Vec<String>;

View File

@ -150,5 +150,4 @@ impl DatabaseExecutor for SpiExecutor {
}) })
}) })
} }
} }

View File

@ -138,7 +138,9 @@ impl Merger {
is_child: bool, is_child: bool,
) -> Result<Value, String> { ) -> Result<Value, String> {
match data { match data {
Value::Array(items) => self.merge_array(schema, items, notifications, parent_org_id, is_child), Value::Array(items) => {
self.merge_array(schema, items, notifications, parent_org_id, is_child)
}
Value::Object(map) => { Value::Object(map) => {
if let Some(options) = schema.obj.compiled_options.get() { if let Some(options) = schema.obj.compiled_options.get() {
if let Some(disc) = schema.obj.compiled_discriminator.get() { if let Some(disc) = schema.obj.compiled_discriminator.get() {
@ -210,7 +212,13 @@ impl Merger {
let mut resolved_items = Vec::new(); let mut resolved_items = Vec::new();
for item in items { for item in items {
let resolved = self.merge_internal(item_schema.clone(), item, notifications, parent_org_id.clone(), is_child)?; let resolved = self.merge_internal(
item_schema.clone(),
item,
notifications,
parent_org_id.clone(),
is_child,
)?;
resolved_items.push(resolved); resolved_items.push(resolved);
} }
Ok(Value::Array(resolved_items)) Ok(Value::Array(resolved_items))
@ -340,7 +348,10 @@ impl Merger {
if let Some(relation) = self.db.relations.get(&edge.constraint) { if let Some(relation) = self.db.relations.get(&edge.constraint) {
let parent_is_source = edge.forward; let parent_is_source = edge.forward;
let org_id_to_pass = entity_fields.get("organization_id").and_then(|v| v.as_str()).map(|s| s.to_string()); let org_id_to_pass = entity_fields
.get("organization_id")
.and_then(|v| v.as_str())
.map(|s| s.to_string());
if parent_is_source { if parent_is_source {
let mut merged_relative = match self.merge_internal( let mut merged_relative = match self.merge_internal(
rel_schema.clone(), rel_schema.clone(),
@ -443,7 +454,10 @@ impl Merger {
} }
} }
let org_id_to_pass = entity_fields.get("organization_id").and_then(|v| v.as_str()).map(|s| s.to_string()); let org_id_to_pass = entity_fields
.get("organization_id")
.and_then(|v| v.as_str())
.map(|s| s.to_string());
let mut relative_responses = Vec::new(); let mut relative_responses = Vec::new();
for relative_item_val in relative_arr { for relative_item_val in relative_arr {
if let Value::Object(mut relative_item) = relative_item_val { if let Value::Object(mut relative_item) = relative_item_val {
@ -946,12 +960,10 @@ impl Merger {
Value::Object(old_vals) Value::Object(old_vals)
}; };
let entity_type_name = type_name.as_str().unwrap_or(&type_obj.name);
let mut notification = serde_json::Map::new(); let mut notification = serde_json::Map::new();
notification.insert("kind".to_string(), Value::String(change_kind.to_string()));
notification.insert("complete".to_string(), Value::Object(complete)); notification.insert("complete".to_string(), Value::Object(complete));
notification.insert("new".to_string(), new_val_obj.clone()); notification.insert("new".to_string(), new_val_obj.clone());
notification.insert("kind".to_string(), Value::String(change_kind.to_string()));
if old_val_obj != Value::Null { if old_val_obj != Value::Null {
notification.insert("old".to_string(), old_val_obj.clone()); notification.insert("old".to_string(), old_val_obj.clone());
@ -964,15 +976,14 @@ impl Merger {
let mut notify_sql = None; let mut notify_sql = None;
if type_obj.historical && change_kind != "replace" { if type_obj.historical && change_kind != "replace" {
let change_sql = format!( let change_sql = format!(
"INSERT INTO agreego.change (\"old\", \"new\", \"entity_id\", \"id\", \"kind\", \"modified_at\", \"modified_by\", \"entity_type\") VALUES ({}, {}, {}, {}, {}, {}, {}, {})", "INSERT INTO agreego.change (\"old\", \"new\", \"entity_id\", \"id\", \"kind\", \"modified_at\", \"modified_by\") VALUES ({}, {}, {}, {}, {}, {}, {})",
Self::quote_literal(&old_val_obj), Self::quote_literal(&old_val_obj),
Self::quote_literal(&new_val_obj), Self::quote_literal(&new_val_obj),
Self::quote_literal(id_str), Self::quote_literal(id_str),
Self::quote_literal(&Value::String(uuid::Uuid::new_v4().to_string())), Self::quote_literal(&Value::String(uuid::Uuid::new_v4().to_string())),
Self::quote_literal(&Value::String(change_kind.to_string())), Self::quote_literal(&Value::String(change_kind.to_string())),
Self::quote_literal(&Value::String(timestamp.to_string())), Self::quote_literal(&Value::String(timestamp.to_string())),
Self::quote_literal(&Value::String(user_id.to_string())), Self::quote_literal(&Value::String(user_id.to_string()))
Self::quote_literal(&Value::String(entity_type_name.to_string()))
); );
self.db.execute(&change_sql, None)?; self.db.execute(&change_sql, None)?;