Compare commits
4 Commits
1.0.154
...
7e28eb2645
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e28eb2645 | |||
| 5133283795 | |||
| d41209e7c1 | |||
| 03c60f5156 |
@ -1242,7 +1242,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -1255,7 +1256,8 @@
|
|||||||
" '{{uuid:generated_1}}',",
|
" '{{uuid:generated_1}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'person'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -1274,7 +1276,8 @@
|
|||||||
" \"first_name\": \"IncompleteFirst\",",
|
" \"first_name\": \"IncompleteFirst\",",
|
||||||
" \"last_name\": \"IncompleteLast\",",
|
" \"last_name\": \"IncompleteLast\",",
|
||||||
" \"type\": \"person\"",
|
" \"type\": \"person\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -1339,7 +1342,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" '{",
|
" '{",
|
||||||
@ -1353,7 +1357,8 @@
|
|||||||
" '{{uuid:generated_0}}',",
|
" '{{uuid:generated_0}}',",
|
||||||
" 'update',",
|
" 'update',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'person'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -1373,6 +1378,7 @@
|
|||||||
" \"contact_id\": \"abc-contact\",",
|
" \"contact_id\": \"abc-contact\",",
|
||||||
" \"type\": \"person\"",
|
" \"type\": \"person\"",
|
||||||
" },",
|
" },",
|
||||||
|
" \"kind\": \"update\",",
|
||||||
" \"old\": {",
|
" \"old\": {",
|
||||||
" \"contact_id\": \"old-contact\"",
|
" \"contact_id\": \"old-contact\"",
|
||||||
" }",
|
" }",
|
||||||
@ -1442,7 +1448,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" '{",
|
" '{",
|
||||||
@ -1456,7 +1463,8 @@
|
|||||||
" '{{uuid:generated_0}}',",
|
" '{{uuid:generated_0}}',",
|
||||||
" 'update',",
|
" 'update',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'person'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -1476,6 +1484,7 @@
|
|||||||
" \"contact_id\": \"abc-contact\",",
|
" \"contact_id\": \"abc-contact\",",
|
||||||
" \"type\": \"person\"",
|
" \"type\": \"person\"",
|
||||||
" },",
|
" },",
|
||||||
|
" \"kind\": \"update\",",
|
||||||
" \"old\": {",
|
" \"old\": {",
|
||||||
" \"contact_id\": \"old-contact\"",
|
" \"contact_id\": \"old-contact\"",
|
||||||
" },",
|
" },",
|
||||||
@ -1540,6 +1549,7 @@
|
|||||||
" \"new\": {",
|
" \"new\": {",
|
||||||
" \"type\": \"person\"",
|
" \"type\": \"person\"",
|
||||||
" },",
|
" },",
|
||||||
|
" \"kind\": \"replace\",",
|
||||||
" \"replaces\": \"{{uuid:data.id}}\"",
|
" \"replaces\": \"{{uuid:data.id}}\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
@ -1598,7 +1608,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" '{",
|
" '{",
|
||||||
@ -1614,7 +1625,8 @@
|
|||||||
" '{{uuid:generated_0}}',",
|
" '{{uuid:generated_0}}',",
|
||||||
" 'update',",
|
" 'update',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'person'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -1632,6 +1644,7 @@
|
|||||||
" \"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\"",
|
||||||
@ -1729,7 +1742,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -1744,7 +1758,8 @@
|
|||||||
" '{{uuid:generated_0}}',",
|
" '{{uuid:generated_0}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'person'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -1767,7 +1782,8 @@
|
|||||||
" \"date_of_birth\": \"{{timestamp}}\",",
|
" \"date_of_birth\": \"{{timestamp}}\",",
|
||||||
" \"pronouns\": \"\",",
|
" \"pronouns\": \"\",",
|
||||||
" \"type\": \"person\"",
|
" \"type\": \"person\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -1854,7 +1870,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -1869,7 +1886,8 @@
|
|||||||
" '{{uuid:generated_2}}',",
|
" '{{uuid:generated_2}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'person'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -1912,7 +1930,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -1925,7 +1944,8 @@
|
|||||||
" '{{uuid:generated_4}}',",
|
" '{{uuid:generated_4}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'order'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -1944,7 +1964,8 @@
|
|||||||
" \"total\": 100.0,",
|
" \"total\": 100.0,",
|
||||||
" \"type\": \"order\",",
|
" \"type\": \"order\",",
|
||||||
" \"customer_id\": \"{{uuid:generated_0}}\"",
|
" \"customer_id\": \"{{uuid:generated_0}}\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -1967,7 +1988,8 @@
|
|||||||
" \"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\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -2072,7 +2094,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2086,7 +2109,8 @@
|
|||||||
" '{{uuid:generated_1}}',",
|
" '{{uuid:generated_1}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'order_line'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2097,7 +2121,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2109,7 +2134,8 @@
|
|||||||
" '{{uuid:generated_2}}',",
|
" '{{uuid:generated_2}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'order'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2126,7 +2152,8 @@
|
|||||||
" \"new\": {",
|
" \"new\": {",
|
||||||
" \"total\": 99.0,",
|
" \"total\": 99.0,",
|
||||||
" \"type\": \"order\"",
|
" \"type\": \"order\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2147,7 +2174,8 @@
|
|||||||
" \"price\": 99.0,",
|
" \"price\": 99.0,",
|
||||||
" \"order_id\": \"abc\",",
|
" \"order_id\": \"abc\",",
|
||||||
" \"type\": \"order_line\"",
|
" \"type\": \"order_line\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -2279,7 +2307,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2291,7 +2320,8 @@
|
|||||||
" '{{uuid:generated_2}}',",
|
" '{{uuid:generated_2}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'phone_number'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2342,7 +2372,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2358,7 +2389,8 @@
|
|||||||
" '{{uuid:generated_4}}',",
|
" '{{uuid:generated_4}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'contact'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2395,7 +2427,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2407,7 +2440,8 @@
|
|||||||
" '{{uuid:generated_6}}',",
|
" '{{uuid:generated_6}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'email_address'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2458,7 +2492,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2474,7 +2509,8 @@
|
|||||||
" '{{uuid:generated_8}}',",
|
" '{{uuid:generated_8}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'contact'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2511,7 +2547,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2523,7 +2560,8 @@
|
|||||||
" '{{uuid:generated_10}}',",
|
" '{{uuid:generated_10}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'email_address'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2574,7 +2612,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2590,7 +2629,8 @@
|
|||||||
" '{{uuid:generated_12}}',",
|
" '{{uuid:generated_12}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'contact'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2601,7 +2641,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2614,7 +2655,8 @@
|
|||||||
" '{{uuid:generated_13}}',",
|
" '{{uuid:generated_13}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'person'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2633,7 +2675,8 @@
|
|||||||
" \"first_name\": \"Relation\",",
|
" \"first_name\": \"Relation\",",
|
||||||
" \"last_name\": \"Test\",",
|
" \"last_name\": \"Test\",",
|
||||||
" \"type\": \"person\"",
|
" \"type\": \"person\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2658,7 +2701,8 @@
|
|||||||
" \"target_id\": \"{{uuid:generated_1}}\",",
|
" \"target_id\": \"{{uuid:generated_1}}\",",
|
||||||
" \"target_type\": \"phone_number\",",
|
" \"target_type\": \"phone_number\",",
|
||||||
" \"type\": \"contact\"",
|
" \"type\": \"contact\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2675,7 +2719,8 @@
|
|||||||
" \"new\": {",
|
" \"new\": {",
|
||||||
" \"number\": \"555-0001\",",
|
" \"number\": \"555-0001\",",
|
||||||
" \"type\": \"phone_number\"",
|
" \"type\": \"phone_number\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2700,7 +2745,8 @@
|
|||||||
" \"target_id\": \"{{uuid:generated_5}}\",",
|
" \"target_id\": \"{{uuid:generated_5}}\",",
|
||||||
" \"target_type\": \"email_address\",",
|
" \"target_type\": \"email_address\",",
|
||||||
" \"type\": \"contact\"",
|
" \"type\": \"contact\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2717,7 +2763,8 @@
|
|||||||
" \"new\": {",
|
" \"new\": {",
|
||||||
" \"address\": \"test@example.com\",",
|
" \"address\": \"test@example.com\",",
|
||||||
" \"type\": \"email_address\"",
|
" \"type\": \"email_address\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2742,7 +2789,8 @@
|
|||||||
" \"target_id\": \"{{uuid:generated_9}}\",",
|
" \"target_id\": \"{{uuid:generated_9}}\",",
|
||||||
" \"target_type\": \"email_address\",",
|
" \"target_type\": \"email_address\",",
|
||||||
" \"type\": \"contact\"",
|
" \"type\": \"contact\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2759,7 +2807,8 @@
|
|||||||
" \"new\": {",
|
" \"new\": {",
|
||||||
" \"address\": \"test2@example.com\",",
|
" \"address\": \"test2@example.com\",",
|
||||||
" \"type\": \"email_address\"",
|
" \"type\": \"email_address\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -2811,7 +2860,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" '{",
|
" '{",
|
||||||
@ -2825,7 +2875,8 @@
|
|||||||
" '{{uuid:generated_0}}',",
|
" '{{uuid:generated_0}}',",
|
||||||
" 'delete',",
|
" 'delete',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'person'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2843,6 +2894,7 @@
|
|||||||
" \"archived\": true,",
|
" \"archived\": true,",
|
||||||
" \"type\": \"person\"",
|
" \"type\": \"person\"",
|
||||||
" },",
|
" },",
|
||||||
|
" \"kind\": \"delete\",",
|
||||||
" \"old\": {",
|
" \"old\": {",
|
||||||
" \"archived\": false",
|
" \"archived\": false",
|
||||||
" }",
|
" }",
|
||||||
@ -2917,7 +2969,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -2938,7 +2991,8 @@
|
|||||||
" '{{uuid:generated_1}}',",
|
" '{{uuid:generated_1}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'attachment'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -2973,7 +3027,8 @@
|
|||||||
" \"type\": \"type_metadata\"",
|
" \"type\": \"type_metadata\"",
|
||||||
" },",
|
" },",
|
||||||
" \"type\": \"attachment\"",
|
" \"type\": \"attachment\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -3039,7 +3094,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -3053,7 +3109,8 @@
|
|||||||
" '{{uuid:generated_1}}',",
|
" '{{uuid:generated_1}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'order_line'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3074,7 +3131,8 @@
|
|||||||
" \"price\": 99.0,",
|
" \"price\": 99.0,",
|
||||||
" \"order_id\": \"abc\",",
|
" \"order_id\": \"abc\",",
|
||||||
" \"type\": \"order_line\"",
|
" \"type\": \"order_line\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -3148,7 +3206,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -3162,7 +3221,8 @@
|
|||||||
" '{{uuid:generated_0}}',",
|
" '{{uuid:generated_0}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'order_line'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3183,7 +3243,8 @@
|
|||||||
" \"price\": 99.0,",
|
" \"price\": 99.0,",
|
||||||
" \"order_id\": \"abc\",",
|
" \"order_id\": \"abc\",",
|
||||||
" \"type\": \"order_line\"",
|
" \"type\": \"order_line\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -3288,7 +3349,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -3320,7 +3382,8 @@
|
|||||||
" '{{uuid:generated_0}}',",
|
" '{{uuid:generated_0}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'invoice'",
|
||||||
")"
|
")"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -3386,7 +3449,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -3399,7 +3463,8 @@
|
|||||||
" '{{uuid:generated_0}}',",
|
" '{{uuid:generated_0}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'account'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3418,7 +3483,8 @@
|
|||||||
" \"kind\": \"checking\",",
|
" \"kind\": \"checking\",",
|
||||||
" \"routing_number\": \"123456789\",",
|
" \"routing_number\": \"123456789\",",
|
||||||
" \"type\": \"account\"",
|
" \"type\": \"account\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -3511,7 +3577,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -3525,7 +3592,8 @@
|
|||||||
" '{{uuid:generated_2}}',",
|
" '{{uuid:generated_2}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'person'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3600,7 +3668,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -3613,7 +3682,8 @@
|
|||||||
" '{{uuid:generated_5}}',",
|
" '{{uuid:generated_5}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'order_line'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3656,7 +3726,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -3669,7 +3740,8 @@
|
|||||||
" '{{uuid:generated_7}}',",
|
" '{{uuid:generated_7}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'order_line'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3680,7 +3752,8 @@
|
|||||||
" \"id\",",
|
" \"id\",",
|
||||||
" \"kind\",",
|
" \"kind\",",
|
||||||
" \"modified_at\",",
|
" \"modified_at\",",
|
||||||
" \"modified_by\"",
|
" \"modified_by\",",
|
||||||
|
" \"entity_type\"",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" NULL,",
|
" NULL,",
|
||||||
@ -3693,7 +3766,8 @@
|
|||||||
" '{{uuid:generated_8}}',",
|
" '{{uuid:generated_8}}',",
|
||||||
" 'create',",
|
" 'create',",
|
||||||
" '{{timestamp}}',",
|
" '{{timestamp}}',",
|
||||||
" '00000000-0000-0000-0000-000000000000'",
|
" '00000000-0000-0000-0000-000000000000',",
|
||||||
|
" 'order'",
|
||||||
")"
|
")"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3712,7 +3786,8 @@
|
|||||||
" \"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\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3733,7 +3808,8 @@
|
|||||||
" \"last_name\": \"Person\",",
|
" \"last_name\": \"Person\",",
|
||||||
" \"type\": \"person\",",
|
" \"type\": \"person\",",
|
||||||
" \"organization_id\": \"{{uuid:generated_1}}\"",
|
" \"organization_id\": \"{{uuid:generated_1}}\"",
|
||||||
" }",
|
" },",
|
||||||
|
" \"kind\": \"create\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3752,7 +3828,8 @@
|
|||||||
" \"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\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -3771,7 +3848,8 @@
|
|||||||
" \"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\"",
|
||||||
"}'))"
|
"}'))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
@ -85,13 +85,6 @@ impl DatabaseExecutor for MockExecutor {
|
|||||||
Ok("2026-03-10T00:00:00Z".to_string())
|
Ok("2026-03-10T00:00:00Z".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn auth_origin(&self) -> Result<Option<Value>, String> {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn punc_trigger(&self) -> Result<Option<String>, String> {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn get_queries(&self) -> Vec<String> {
|
fn get_queries(&self) -> Vec<String> {
|
||||||
|
|||||||
@ -20,11 +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>;
|
||||||
|
|
||||||
/// Returns the current auth.origin session context if configured
|
|
||||||
fn auth_origin(&self) -> Result<Option<Value>, String>;
|
|
||||||
|
|
||||||
/// Returns the current punc.name session context if configured
|
|
||||||
fn punc_trigger(&self) -> Result<Option<String>, String>;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn get_queries(&self) -> Vec<String>;
|
fn get_queries(&self) -> Vec<String>;
|
||||||
|
|||||||
@ -151,41 +151,4 @@ impl DatabaseExecutor for SpiExecutor {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn auth_origin(&self) -> Result<Option<Value>, String> {
|
|
||||||
Spi::connect(|client| {
|
|
||||||
let mut tup_table = client
|
|
||||||
.select(
|
|
||||||
"SELECT NULLIF(current_setting('auth.origin', true), '')::jsonb",
|
|
||||||
None,
|
|
||||||
&[],
|
|
||||||
)
|
|
||||||
.map_err(|e| format!("SPI Select Error: {}", e))?;
|
|
||||||
|
|
||||||
if let Some(row) = tup_table.next() {
|
|
||||||
if let Ok(Some(jsonb)) = row.get::<pgrx::JsonB>(1) {
|
|
||||||
return Ok(Some(jsonb.0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(None)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn punc_trigger(&self) -> Result<Option<String>, String> {
|
|
||||||
Spi::connect(|client| {
|
|
||||||
let mut tup_table = client
|
|
||||||
.select(
|
|
||||||
"SELECT NULLIF(current_setting('punc.name', true), '')",
|
|
||||||
None,
|
|
||||||
&[],
|
|
||||||
)
|
|
||||||
.map_err(|e| format!("SPI Select Error: {}", e))?;
|
|
||||||
|
|
||||||
if let Some(row) = tup_table.next() {
|
|
||||||
if let Ok(val_opt) = row.get::<String>(1) {
|
|
||||||
return Ok(val_opt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(None)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -206,15 +206,6 @@ impl Database {
|
|||||||
self.executor.timestamp()
|
self.executor.timestamp()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the current auth.origin session context if configured
|
|
||||||
pub fn auth_origin(&self) -> Result<Option<Value>, String> {
|
|
||||||
self.executor.auth_origin()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the current punc.name session context if configured
|
|
||||||
pub fn punc_trigger(&self) -> Result<Option<String>, String> {
|
|
||||||
self.executor.punc_trigger()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn compile(&mut self, errors: &mut Vec<crate::drop::Error>) {
|
pub fn compile(&mut self, errors: &mut Vec<crate::drop::Error>) {
|
||||||
// Phase 1: Registration
|
// Phase 1: Registration
|
||||||
|
|||||||
@ -946,27 +946,12 @@ impl Merger {
|
|||||||
Value::Object(old_vals)
|
Value::Object(old_vals)
|
||||||
};
|
};
|
||||||
|
|
||||||
let origin = match self.db.auth_origin() {
|
|
||||||
Ok(Some(orig)) => orig,
|
|
||||||
_ => serde_json::json!({
|
|
||||||
"kind": "user",
|
|
||||||
"user_id": user_id
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
let trigger = match self.db.punc_trigger() {
|
|
||||||
Ok(Some(trig)) => trig,
|
|
||||||
_ => "merge_entity".to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let entity_type_name = type_name.as_str().unwrap_or(&type_obj.name);
|
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("type".to_string(), Value::String(entity_type_name.to_string()));
|
|
||||||
notification.insert("trigger".to_string(), Value::String(trigger));
|
|
||||||
notification.insert("origin".to_string(), origin.clone());
|
|
||||||
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());
|
||||||
@ -979,7 +964,7 @@ 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, origin, entity_type) VALUES ({}, {}, {}, {}, {}, {}, {}, {}, {})",
|
"INSERT INTO agreego.change (\"old\", \"new\", \"entity_id\", \"id\", \"kind\", \"modified_at\", \"modified_by\", \"entity_type\") 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),
|
||||||
@ -987,7 +972,6 @@ impl Merger {
|
|||||||
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(&origin),
|
|
||||||
Self::quote_literal(&Value::String(entity_type_name.to_string()))
|
Self::quote_literal(&Value::String(entity_type_name.to_string()))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -96,8 +96,10 @@ impl Case {
|
|||||||
let queries = db.executor.get_queries();
|
let queries = db.executor.get_queries();
|
||||||
if std::env::var("UPDATE_EXPECT").is_ok() {
|
if std::env::var("UPDATE_EXPECT").is_ok() {
|
||||||
crate::tests::runner::update_sql_fixture(path, suite_idx, case_idx, &queries);
|
crate::tests::runner::update_sql_fixture(path, suite_idx, case_idx, &queries);
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
expect.assert_sql(&queries)
|
||||||
}
|
}
|
||||||
expect.assert_sql(&queries)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -128,8 +130,10 @@ impl Case {
|
|||||||
let queries = db.executor.get_queries();
|
let queries = db.executor.get_queries();
|
||||||
if std::env::var("UPDATE_EXPECT").is_ok() {
|
if std::env::var("UPDATE_EXPECT").is_ok() {
|
||||||
crate::tests::runner::update_sql_fixture(path, suite_idx, case_idx, &queries);
|
crate::tests::runner::update_sql_fixture(path, suite_idx, case_idx, &queries);
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
expect.assert_sql(&queries)
|
||||||
}
|
}
|
||||||
expect.assert_sql(&queries)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
pub mod pattern;
|
|
||||||
pub mod sql;
|
pub mod sql;
|
||||||
pub mod drop;
|
pub mod drop;
|
||||||
pub mod schema;
|
pub mod schema;
|
||||||
|
|||||||
@ -1,132 +0,0 @@
|
|||||||
use super::Expect;
|
|
||||||
use regex::Regex;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
impl Expect {
|
|
||||||
/// Advanced SQL execution assertion algorithm ported from `assert.go`.
|
|
||||||
/// This compares two arrays of strings, one containing {{uuid:name}} or {{timestamp}} placeholders,
|
|
||||||
/// and the other containing actual executed database queries. It ensures that placeholder UUIDs
|
|
||||||
/// are consistently mapped to the same actual UUIDs across all lines, and strictly validates line-by-line sequences.
|
|
||||||
pub fn assert_pattern(&self, actual: &[String]) -> Result<(), String> {
|
|
||||||
let patterns = match &self.sql {
|
|
||||||
Some(s) => s,
|
|
||||||
None => return Ok(()),
|
|
||||||
};
|
|
||||||
|
|
||||||
if patterns.len() != actual.len() {
|
|
||||||
return Err(format!(
|
|
||||||
"Length mismatch: expected {} SQL executions, got {}.\nActual Execution Log:\n{}",
|
|
||||||
patterns.len(),
|
|
||||||
actual.len(),
|
|
||||||
actual.join("\n")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let ws_re = Regex::new(r"\s+").unwrap();
|
|
||||||
|
|
||||||
let types = HashMap::from([
|
|
||||||
(
|
|
||||||
"uuid",
|
|
||||||
r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"timestamp",
|
|
||||||
r"\d{4}-\d{2}-\d{2}(?:[ T])\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+\d{2}(?::\d{2})?)?",
|
|
||||||
),
|
|
||||||
("integer", r"-?\d+"),
|
|
||||||
("float", r"-?\d+\.\d+"),
|
|
||||||
("text", r"(?:''|[^'])*"),
|
|
||||||
("json", r"(?:''|[^'])*"),
|
|
||||||
]);
|
|
||||||
|
|
||||||
let mut seen: HashMap<String, String> = HashMap::new();
|
|
||||||
let system_uuid = "00000000-0000-0000-0000-000000000000";
|
|
||||||
|
|
||||||
// Placeholder regex: {{type:name}} or {{type}}
|
|
||||||
let ph_rx = Regex::new(r"\{\{([a-z]+)(?:[:]([^}]+))?\}\}").unwrap();
|
|
||||||
|
|
||||||
let clean_str = |s: &str| -> String {
|
|
||||||
let mut s = ws_re.replace_all(s, " ").into_owned();
|
|
||||||
for token in ["(", ")", ",", "{", "}", "\"", "=", "'"] {
|
|
||||||
s = s.replace(&format!(" {}", token), token);
|
|
||||||
s = s.replace(&format!("{} ", token), token);
|
|
||||||
}
|
|
||||||
s.trim().to_string()
|
|
||||||
};
|
|
||||||
|
|
||||||
for (i, pattern_expect) in patterns.iter().enumerate() {
|
|
||||||
let aline_raw = &actual[i];
|
|
||||||
let aline = clean_str(aline_raw);
|
|
||||||
|
|
||||||
let pattern_str_raw = match pattern_expect {
|
|
||||||
super::SqlExpectation::Single(s) => s.clone(),
|
|
||||||
super::SqlExpectation::Multi(m) => m.join(" "),
|
|
||||||
};
|
|
||||||
|
|
||||||
let pattern_str = clean_str(&pattern_str_raw);
|
|
||||||
|
|
||||||
let mut pp = regex::escape(&pattern_str);
|
|
||||||
pp = pp.replace(r"\{\{", "{{").replace(r"\}\}", "}}");
|
|
||||||
|
|
||||||
let mut cap_names = HashMap::new(); // cg_X -> var_name
|
|
||||||
let mut group_idx = 0;
|
|
||||||
|
|
||||||
let mut final_rx_str = String::new();
|
|
||||||
let mut last_match = 0;
|
|
||||||
|
|
||||||
let pp_clone = pp.clone();
|
|
||||||
for caps in ph_rx.captures_iter(&pp_clone) {
|
|
||||||
let full_match = caps.get(0).unwrap();
|
|
||||||
final_rx_str.push_str(&pp[last_match..full_match.start()]);
|
|
||||||
|
|
||||||
let type_name = caps.get(1).unwrap().as_str();
|
|
||||||
let var_name = caps.get(2).map(|m| m.as_str());
|
|
||||||
|
|
||||||
if let Some(name) = var_name {
|
|
||||||
if let Some(val) = seen.get(name) {
|
|
||||||
final_rx_str.push_str(®ex::escape(val));
|
|
||||||
} else {
|
|
||||||
let type_pattern = types.get(type_name).unwrap_or(&".*?");
|
|
||||||
let cg_name = format!("cg_{}", group_idx);
|
|
||||||
final_rx_str.push_str(&format!("(?P<{}>{})", cg_name, type_pattern));
|
|
||||||
cap_names.insert(cg_name, name.to_string());
|
|
||||||
group_idx += 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let type_pattern = types.get(type_name).unwrap_or(&".*?");
|
|
||||||
final_rx_str.push_str(&format!("(?:{})", type_pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
last_match = full_match.end();
|
|
||||||
}
|
|
||||||
final_rx_str.push_str(&pp[last_match..]);
|
|
||||||
|
|
||||||
let final_rx = match Regex::new(&format!("^{}$", final_rx_str)) {
|
|
||||||
Ok(r) => r,
|
|
||||||
Err(e) => return Err(format!("Bad constructed regex: {} -> {}", final_rx_str, e)),
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(captures) = final_rx.captures(&aline) {
|
|
||||||
for (cg_name, var_name) in cap_names {
|
|
||||||
if let Some(m) = captures.name(&cg_name) {
|
|
||||||
let matched_str = m.as_str();
|
|
||||||
if matched_str != system_uuid {
|
|
||||||
seen.insert(var_name, matched_str.to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return Err(format!(
|
|
||||||
"Line mismatched at execution sequence {}.\nExpected Pattern: {}\nActual SQL: {}\nRegex used: {}\nVariables Mapped: {:?}",
|
|
||||||
i + 1,
|
|
||||||
pattern_str,
|
|
||||||
aline,
|
|
||||||
final_rx_str,
|
|
||||||
seen
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +1,9 @@
|
|||||||
use super::Expect;
|
use super::Expect;
|
||||||
|
use regex::Regex;
|
||||||
use sqlparser::ast::{Expr, Query, SelectItem, Statement, TableFactor};
|
use sqlparser::ast::{Expr, Query, SelectItem, Statement, TableFactor};
|
||||||
use sqlparser::dialect::PostgreSqlDialect;
|
use sqlparser::dialect::PostgreSqlDialect;
|
||||||
use sqlparser::parser::Parser;
|
use sqlparser::parser::Parser;
|
||||||
use std::collections::HashSet;
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
impl Expect {
|
impl Expect {
|
||||||
pub fn assert_sql(&self, actual: &[String]) -> Result<(), String> {
|
pub fn assert_sql(&self, actual: &[String]) -> Result<(), String> {
|
||||||
@ -11,6 +12,7 @@ impl Expect {
|
|||||||
return Err(e);
|
return Err(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.assert_pattern(actual)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,4 +205,132 @@ impl Expect {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Advanced SQL execution assertion algorithm ported from `assert.go`.
|
||||||
|
/// This compares two arrays of strings, one containing {{uuid:name}} or {{timestamp}} placeholders,
|
||||||
|
/// and the other containing actual executed database queries. It ensures that placeholder UUIDs
|
||||||
|
/// are consistently mapped to the same actual UUIDs across all lines, and strictly validates line-by-line sequences.
|
||||||
|
pub fn assert_pattern(&self, actual: &[String]) -> Result<(), String> {
|
||||||
|
let patterns = match &self.sql {
|
||||||
|
Some(s) => s,
|
||||||
|
None => return Ok(()),
|
||||||
|
};
|
||||||
|
|
||||||
|
if patterns.len() != actual.len() {
|
||||||
|
return Err(format!(
|
||||||
|
"Length mismatch: expected {} SQL executions, got {}.\nActual Execution Log:\n{}",
|
||||||
|
patterns.len(),
|
||||||
|
actual.len(),
|
||||||
|
actual.join("\n")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
let ws_re = Regex::new(r"\s+").unwrap();
|
||||||
|
|
||||||
|
let types = HashMap::from([
|
||||||
|
(
|
||||||
|
"uuid",
|
||||||
|
r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"timestamp",
|
||||||
|
r"\d{4}-\d{2}-\d{2}(?:[ T])\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+\d{2}(?::\d{2})?)?",
|
||||||
|
),
|
||||||
|
("integer", r"-?\d+"),
|
||||||
|
("float", r"-?\d+\.\d+"),
|
||||||
|
("text", r"(?:''|[^'])*"),
|
||||||
|
("json", r"(?:''|[^'])*"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
let mut seen: HashMap<String, String> = HashMap::new();
|
||||||
|
let system_uuid = "00000000-0000-0000-0000-000000000000";
|
||||||
|
|
||||||
|
// Placeholder regex: {{type:name}} or {{type}}
|
||||||
|
let ph_rx = Regex::new(r"\{\{([a-z]+)(?:[:]([^}]+))?\}\}").unwrap();
|
||||||
|
|
||||||
|
let clean_str = |s: &str| -> String {
|
||||||
|
let mut s = ws_re.replace_all(s, " ").into_owned();
|
||||||
|
for token in ["(", ")", ",", "{", "}", "\"", "=", "'"] {
|
||||||
|
s = s.replace(&format!(" {}", token), token);
|
||||||
|
s = s.replace(&format!("{} ", token), token);
|
||||||
|
}
|
||||||
|
s.trim().to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i, pattern_expect) in patterns.iter().enumerate() {
|
||||||
|
let aline_raw = &actual[i];
|
||||||
|
let formatted_actual = crate::tests::formatter::SqlFormatter::format(aline_raw).join(" ");
|
||||||
|
let aline = clean_str(&formatted_actual);
|
||||||
|
|
||||||
|
let pattern_str_raw = match pattern_expect {
|
||||||
|
super::SqlExpectation::Single(s) => s.clone(),
|
||||||
|
super::SqlExpectation::Multi(m) => m.join(" "),
|
||||||
|
};
|
||||||
|
|
||||||
|
let pattern_str = clean_str(&pattern_str_raw);
|
||||||
|
|
||||||
|
let mut pp = regex::escape(&pattern_str);
|
||||||
|
pp = pp.replace(r"\{\{", "{{").replace(r"\}\}", "}}");
|
||||||
|
|
||||||
|
let mut cap_names = HashMap::new(); // cg_X -> var_name
|
||||||
|
let mut group_idx = 0;
|
||||||
|
|
||||||
|
let mut final_rx_str = String::new();
|
||||||
|
let mut last_match = 0;
|
||||||
|
|
||||||
|
let pp_clone = pp.clone();
|
||||||
|
for caps in ph_rx.captures_iter(&pp_clone) {
|
||||||
|
let full_match = caps.get(0).unwrap();
|
||||||
|
final_rx_str.push_str(&pp[last_match..full_match.start()]);
|
||||||
|
|
||||||
|
let type_name = caps.get(1).unwrap().as_str();
|
||||||
|
let var_name = caps.get(2).map(|m| m.as_str());
|
||||||
|
|
||||||
|
if let Some(name) = var_name {
|
||||||
|
if let Some(val) = seen.get(name) {
|
||||||
|
final_rx_str.push_str(®ex::escape(val));
|
||||||
|
} else {
|
||||||
|
let type_pattern = types.get(type_name).unwrap_or(&".*?");
|
||||||
|
let cg_name = format!("cg_{}", group_idx);
|
||||||
|
final_rx_str.push_str(&format!("(?P<{}>{})", cg_name, type_pattern));
|
||||||
|
cap_names.insert(cg_name, name.to_string());
|
||||||
|
group_idx += 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let type_pattern = types.get(type_name).unwrap_or(&".*?");
|
||||||
|
final_rx_str.push_str(&format!("(?:{})", type_pattern));
|
||||||
|
}
|
||||||
|
|
||||||
|
last_match = full_match.end();
|
||||||
|
}
|
||||||
|
final_rx_str.push_str(&pp[last_match..]);
|
||||||
|
|
||||||
|
let final_rx = match Regex::new(&format!("^{}$", final_rx_str)) {
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(e) => return Err(format!("Bad constructed regex: {} -> {}", final_rx_str, e)),
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(captures) = final_rx.captures(&aline) {
|
||||||
|
for (cg_name, var_name) in cap_names {
|
||||||
|
if let Some(m) = captures.name(&cg_name) {
|
||||||
|
let matched_str = m.as_str();
|
||||||
|
if matched_str != system_uuid {
|
||||||
|
seen.insert(var_name, matched_str.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Err(format!(
|
||||||
|
"Line mismatched at execution sequence {}.\nExpected Pattern: {}\nActual SQL: {}\nRegex used: {}\nVariables Mapped: {:?}",
|
||||||
|
i + 1,
|
||||||
|
pattern_str,
|
||||||
|
aline,
|
||||||
|
final_rx_str,
|
||||||
|
seen
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user