Compare commits

..

12 Commits

Author SHA1 Message Date
9e362f2168 version: 1.0.159 2026-06-15 16:44:04 -04:00
9fffc7707f Merge branch 'main' of gitea-ssh.thoughtpatterns.ai:cellular/jspg 2026-06-15 16:42:13 -04:00
c5d652c6fd fixed merger ordering issue 2026-06-15 16:41:59 -04:00
d2cdd680ed insert fix checkpoint 2026-06-15 16:18:44 -04:00
6f1c0d7ee9 version: 1.0.158 2026-06-12 22:11:14 -04:00
25bbf2b564 merger: generate entity and changelog ids with uuid v7
Switch the two UUID generation sites in the merger from v4 to time-ordered
v7, and swap the uuid crate feature flag from v4 to v7 accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 22:11:09 -04:00
c8cc4cbde8 version: 1.0.157 2026-06-11 20:40:36 -04:00
5af2399e3b fixed issue with filter generation where filters or conditions are used internally 2026-06-11 20:40:27 -04:00
1d56bae9a5 version: 1.0.156 2026-06-11 17:37:43 -04:00
813e9ff3c2 more executor reverts 2026-06-11 17:37:34 -04:00
7e28eb2645 added kind to merge notifications, re-instated sql pattern matching 2026-06-11 17:26:07 -04:00
5133283795 checkpoint for re-enabling SQL pattern matching 2026-06-11 15:25:21 -04:00
18 changed files with 1237 additions and 948 deletions

View File

@ -16,7 +16,7 @@ url = "2.5.8"
fluent-uri = "0.3.2"
idna = "1.1.0"
percent-encoding = "2.3.2"
uuid = { version = "1.20.0", features = ["v4", "serde"] }
uuid = { version = "1.20.0", features = ["v7", "serde"] }
chrono = { version = "0.4.43", features = ["serde"] }
json-pointer = "0.3.4"
indexmap = { version = "2.13.0", features = ["serde"] }

View File

@ -175,6 +175,7 @@ In the Punc architecture, filters are automatically synthesized, strongly-typed
* **Conditions**: A condition schema is the contract defining the mathematical operations allowed on a primitive field. For example, a `string.condition` allows `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$of` (IN), and `$nof` (NOT IN).
* **Enum Conditions**: When JSPG synthesizes an enum, it dynamically generates an `<enum>.condition` (e.g., `address_kind.condition`). This strongly-typed condition perfectly mirrors the operations of a `string.condition`, but strictly limits the arrays and inputs of `$eq`, `$ne`, `$of`, and `$nof` to the exact variations defined by that Enum. This context ensures that UI generators know exactly when to render `<Select>` dropdowns instead of generic `<Text>` boxes.
* **Pre-compiled Condition and Filter Mapping**: To prevent redundant double-wrapping of search structures, any schema property whose type is already a `.condition` or `.filter` type (such as `"string.condition"` or `"$kind.filter"`) maps directly to itself during filter synthesis rather than receiving a redundant `.filter` suffix.
* **Filters**: A filter schema (e.g., `person.filter`) is an object containing condition properties used to filter entities. It natively supports structural composition:
* **Inherited Properties**: Filters automatically inherit all valid database columns from their base type schema, immediately converting them to their respective `.condition` schemas.
* **Relational Proxies**: If a table has a foreign key to another table, the filter automatically generates a proxy property pointing to the related entity's filter (e.g., the `person` filter automatically gains an `organization` property that points to `organization.filter`), allowing infinitely deep nested queries natively.

View File

@ -791,8 +791,8 @@
}
},
"hierarchy": [
"invoice",
"entity"
"entity",
"invoice"
],
"fields": [
"id",
@ -867,8 +867,8 @@
}
},
"hierarchy": [
"invoice_line",
"entity"
"entity",
"invoice_line"
],
"fields": [
"id",

View File

@ -466,7 +466,7 @@
},
"filter": {
"type": [
"$kind.filter.filter",
"$kind.filter",
"null"
]
},

View File

@ -110,8 +110,8 @@
}
},
"hierarchy": [
"activity",
"entity"
"entity",
"activity"
],
"variations": [
"activity",
@ -166,9 +166,9 @@
}
},
"hierarchy": [
"invoice",
"entity",
"activity",
"entity"
"invoice"
],
"variations": [
"invoice"
@ -237,8 +237,8 @@
}
},
"hierarchy": [
"attachment",
"entity"
"entity",
"attachment"
],
"variations": [
"attachment"

View File

@ -219,8 +219,8 @@
}
},
"hierarchy": [
"organization",
"entity"
"entity",
"organization"
],
"fields": [
"id",
@ -262,9 +262,9 @@
}
},
"hierarchy": [
"user",
"entity",
"organization",
"entity"
"user"
],
"fields": [
"id",
@ -359,10 +359,10 @@
}
},
"hierarchy": [
"person",
"user",
"entity",
"organization",
"entity"
"user",
"person"
],
"fields": [
"id",
@ -445,8 +445,8 @@
}
},
"hierarchy": [
"order",
"entity"
"entity",
"order"
],
"fields": [
"id",
@ -504,8 +504,8 @@
}
},
"hierarchy": [
"order_line",
"entity"
"entity",
"order_line"
],
"fields": [
"id",
@ -548,8 +548,8 @@
"name": "relationship",
"relationship": true,
"hierarchy": [
"relationship",
"entity"
"entity",
"relationship"
],
"fields": [
"source_id",
@ -611,9 +611,9 @@
"name": "contact",
"relationship": true,
"hierarchy": [
"contact",
"entity",
"relationship",
"entity"
"contact"
],
"fields": [
"is_primary",
@ -683,8 +683,8 @@
{
"name": "phone_number",
"hierarchy": [
"phone_number",
"entity"
"entity",
"phone_number"
],
"fields": [
"number",
@ -741,8 +741,8 @@
{
"name": "email_address",
"hierarchy": [
"email_address",
"entity"
"entity",
"email_address"
],
"fields": [
"address",
@ -834,8 +834,8 @@
}
},
"hierarchy": [
"attachment",
"entity"
"entity",
"attachment"
],
"fields": [
"id",
@ -887,8 +887,8 @@
{
"name": "account",
"hierarchy": [
"account",
"entity"
"entity",
"account"
],
"fields": [
"id",
@ -1031,8 +1031,8 @@
}
},
"hierarchy": [
"invoice",
"entity"
"entity",
"invoice"
],
"fields": [
"id",
@ -1107,8 +1107,8 @@
}
},
"hierarchy": [
"invoice_line",
"entity"
"entity",
"invoice_line"
],
"fields": [
"id",
@ -1260,6 +1260,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"first_name\": \"IncompleteFirst\",",
" \"last_name\": \"IncompleteLast\",",
@ -1308,10 +1309,10 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
"FROM agreego.\"person\" t1",
"JOIN agreego.\"user\" t2 ON ",
"JOIN agreego.\"organization\" t3 ON ",
"JOIN agreego.\"entity\" t4 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"organization\" t2 ON ",
"JOIN agreego.\"user\" t3 ON ",
"JOIN agreego.\"person\" t4 ON ",
"WHERE",
" (\"first_name\" = 'LookupFirst'",
" AND \"last_name\" = 'LookupLast'",
@ -1319,17 +1320,62 @@
" AND \"pronouns\" = 'they/them'))"
],
[
"UPDATE agreego.\"person\" SET",
" contact_id = 'abc-contact'",
"WHERE",
" id = '{{uuid:mocks.0.id}}'"
"INSERT INTO agreego.\"entity\" (",
" \"created_at\",",
" \"created_by\",",
" \"id\",",
" \"modified_at\",",
" \"modified_by\",",
" \"type\"",
")",
"VALUES (",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" '{{uuid:generated_0}}',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" 'person'",
")"
],
[
"UPDATE agreego.\"entity\" SET",
" modified_at = '{{timestamp}}',",
" modified_by = '00000000-0000-0000-0000-000000000000'",
"WHERE",
" id = '{{uuid:mocks.0.id}}'"
"INSERT INTO agreego.\"organization\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" '{{uuid:generated_0}}',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"user\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" '{{uuid:generated_0}}',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"person\" (",
" \"contact_id\",",
" \"date_of_birth\",",
" \"first_name\",",
" \"id\",",
" \"last_name\",",
" \"pronouns\",",
" \"type\"",
")",
"VALUES (",
" 'abc-contact',",
" '{{timestamp}}',",
" 'LookupFirst',",
" '{{uuid:generated_0}}',",
" 'LookupLast',",
" 'they/them',",
" 'person'",
")"
],
[
"INSERT INTO agreego.change (",
@ -1342,39 +1388,45 @@
" \"modified_by\"",
")",
"VALUES (",
" NULL,",
" '{",
" \"contact_id\": \"old-contact\"",
" }',",
" '{",
" \"first_name\": \"LookupFirst\",",
" \"last_name\": \"LookupLast\",",
" \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"they/them\",",
" \"contact_id\": \"abc-contact\",",
" \"type\": \"person\"",
" }',",
" '{{uuid:mocks.0.id}}',",
" '{{uuid:generated_0}}',",
" 'update',",
" '{{uuid:generated_1}}',",
" 'create',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000'",
")"
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"id\": \"{{uuid:mocks.0.id}}\",",
" \"type\": \"person\",",
" \"first_name\": \"LookupFirst\",",
" \"last_name\": \"LookupLast\",",
" \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"they/them\",",
" \"contact_id\": \"abc-contact\",",
" \"id\": \"{{uuid:generated_0}}\",",
" \"type\": \"person\",",
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"created_at\": \"{{timestamp}}\",",
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"modified_at\": \"{{timestamp}}\"",
" },",
" \"new\": {",
" \"first_name\": \"LookupFirst\",",
" \"last_name\": \"LookupLast\",",
" \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"they/them\",",
" \"contact_id\": \"abc-contact\",",
" \"type\": \"person\"",
" },",
" \"old\": {",
" \"contact_id\": \"old-contact\"",
" }",
"}'))"
]
@ -1410,10 +1462,10 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
"FROM agreego.\"person\" t1",
"JOIN agreego.\"user\" t2 ON ",
"JOIN agreego.\"organization\" t3 ON ",
"JOIN agreego.\"entity\" t4 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"organization\" t2 ON ",
"JOIN agreego.\"user\" t3 ON ",
"JOIN agreego.\"person\" t4 ON ",
"WHERE",
" t1.id = '{{uuid:data.id}}'",
" OR (\"first_name\" = 'LookupFirst'",
@ -1422,17 +1474,62 @@
" AND \"pronouns\" = 'they/them'))"
],
[
"UPDATE agreego.\"person\" SET",
" contact_id = 'abc-contact'",
"WHERE",
" id = '{{uuid:mocks.0.id}}'"
"INSERT INTO agreego.\"entity\" (",
" \"created_at\",",
" \"created_by\",",
" \"id\",",
" \"modified_at\",",
" \"modified_by\",",
" \"type\"",
")",
"VALUES (",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" '{{uuid:data.id}}',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" 'person'",
")"
],
[
"UPDATE agreego.\"entity\" SET",
" modified_at = '{{timestamp}}',",
" modified_by = '00000000-0000-0000-0000-000000000000'",
"WHERE",
" id = '{{uuid:mocks.0.id}}'"
"INSERT INTO agreego.\"organization\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" '{{uuid:data.id}}',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"user\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" '{{uuid:data.id}}',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"person\" (",
" \"contact_id\",",
" \"date_of_birth\",",
" \"first_name\",",
" \"id\",",
" \"last_name\",",
" \"pronouns\",",
" \"type\"",
")",
"VALUES (",
" 'abc-contact',",
" '{{timestamp}}',",
" 'LookupFirst',",
" '{{uuid:data.id}}',",
" 'LookupLast',",
" 'they/them',",
" 'person'",
")"
],
[
"INSERT INTO agreego.change (",
@ -1445,41 +1542,46 @@
" \"modified_by\"",
")",
"VALUES (",
" NULL,",
" '{",
" \"contact_id\": \"old-contact\"",
" }',",
" '{",
" \"first_name\": \"LookupFirst\",",
" \"last_name\": \"LookupLast\",",
" \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"they/them\",",
" \"contact_id\": \"abc-contact\",",
" \"type\": \"person\"",
" }',",
" '{{uuid:mocks.0.id}}',",
" '{{uuid:data.id}}',",
" '{{uuid:generated_0}}',",
" 'update',",
" 'create',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000'",
")"
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"id\": \"{{uuid:mocks.0.id}}\",",
" \"type\": \"person\",",
" \"first_name\": \"LookupFirst\",",
" \"last_name\": \"LookupLast\",",
" \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"they/them\",",
" \"contact_id\": \"abc-contact\",",
" \"id\": \"{{uuid:data.id}}\",",
" \"type\": \"person\",",
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"created_at\": \"{{timestamp}}\",",
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"modified_at\": \"{{timestamp}}\"",
" },",
" \"new\": {",
" \"first_name\": \"LookupFirst\",",
" \"last_name\": \"LookupLast\",",
" \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"they/them\",",
" \"contact_id\": \"abc-contact\",",
" \"type\": \"person\"",
" },",
" \"old\": {",
" \"contact_id\": \"old-contact\"",
" },",
" \"replaces\": \"{{uuid:data.id}}\"",
" }",
"}'))"
]
]
@ -1513,10 +1615,10 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
"FROM agreego.\"person\" t1",
"JOIN agreego.\"user\" t2 ON ",
"JOIN agreego.\"organization\" t3 ON ",
"JOIN agreego.\"entity\" t4 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"organization\" t2 ON ",
"JOIN agreego.\"user\" t3 ON ",
"JOIN agreego.\"person\" t4 ON ",
"WHERE",
" t1.id = '{{uuid:data.id}}'",
" OR (\"first_name\" = 'LookupFirst'",
@ -1525,22 +1627,109 @@
" AND \"pronouns\" = 'they/them'))"
],
[
"(SELECT pg_notify('entity', '{",
" \"complete\": {",
" \"id\": \"{{uuid:mocks.0.id}}\",",
" \"type\": \"person\",",
"INSERT INTO agreego.\"entity\" (",
" \"created_at\",",
" \"created_by\",",
" \"id\",",
" \"modified_at\",",
" \"modified_by\",",
" \"type\"",
")",
"VALUES (",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" '{{uuid:data.id}}',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"organization\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" '{{uuid:data.id}}',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"user\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" '{{uuid:data.id}}',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"person\" (",
" \"date_of_birth\",",
" \"first_name\",",
" \"id\",",
" \"last_name\",",
" \"pronouns\",",
" \"type\"",
")",
"VALUES (",
" '{{timestamp}}',",
" 'LookupFirst',",
" '{{uuid:data.id}}',",
" 'LookupLast',",
" 'they/them',",
" 'person'",
")"
],
[
"INSERT INTO agreego.change (",
" \"old\",",
" \"new\",",
" \"entity_id\",",
" \"id\",",
" \"kind\",",
" \"modified_at\",",
" \"modified_by\"",
")",
"VALUES (",
" NULL,",
" '{",
" \"first_name\": \"LookupFirst\",",
" \"last_name\": \"LookupLast\",",
" \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"they/them\",",
" \"contact_id\": \"old-contact\",",
" \"type\": \"person\"",
" }',",
" '{{uuid:data.id}}',",
" '{{uuid:generated_0}}',",
" 'create',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000'",
")"
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"first_name\": \"LookupFirst\",",
" \"last_name\": \"LookupLast\",",
" \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"they/them\",",
" \"id\": \"{{uuid:data.id}}\",",
" \"type\": \"person\",",
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"created_at\": \"{{timestamp}}\",",
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"modified_at\": \"{{timestamp}}\"",
" },",
" \"new\": {",
" \"first_name\": \"LookupFirst\",",
" \"last_name\": \"LookupLast\",",
" \"date_of_birth\": \"{{timestamp}}\",",
" \"pronouns\": \"they/them\",",
" \"type\": \"person\"",
" },",
" \"replaces\": \"{{uuid:data.id}}\"",
" }",
"}'))"
]
]
@ -1569,26 +1758,64 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
"FROM agreego.\"person\" t1",
"JOIN agreego.\"user\" t2 ON ",
"JOIN agreego.\"organization\" t3 ON ",
"JOIN agreego.\"entity\" t4 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"organization\" t2 ON ",
"JOIN agreego.\"user\" t3 ON ",
"JOIN agreego.\"person\" t4 ON ",
"WHERE",
" t1.id = '{{uuid:mocks.0.id}}')"
],
[
"UPDATE agreego.\"person\" SET",
" first_name = 'NewFirst',",
" last_name = 'NewLast'",
"WHERE",
" id = '{{uuid:mocks.0.id}}'"
"INSERT INTO agreego.\"entity\" (",
" \"created_at\",",
" \"created_by\",",
" \"id\",",
" \"modified_at\",",
" \"modified_by\",",
" \"type\"",
")",
"VALUES (",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" '{{uuid:mocks.0.id}}',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" 'person'",
")"
],
[
"UPDATE agreego.\"entity\" SET",
" modified_at = '{{timestamp}}',",
" modified_by = '00000000-0000-0000-0000-000000000000'",
"WHERE",
" id = '{{uuid:mocks.0.id}}'"
"INSERT INTO agreego.\"organization\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" '{{uuid:mocks.0.id}}',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"user\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" '{{uuid:mocks.0.id}}',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"person\" (",
" \"first_name\",",
" \"id\",",
" \"last_name\",",
" \"type\"",
")",
"VALUES (",
" 'NewFirst',",
" '{{uuid:mocks.0.id}}',",
" 'NewLast',",
" 'person'",
")"
],
[
"INSERT INTO agreego.change (",
@ -1601,10 +1828,7 @@
" \"modified_by\"",
")",
"VALUES (",
" '{",
" \"first_name\": \"OldFirst\",",
" \"last_name\": \"OldLast\"",
" }',",
" NULL,",
" '{",
" \"first_name\": \"NewFirst\",",
" \"last_name\": \"NewLast\",",
@ -1612,18 +1836,21 @@
" }',",
" '{{uuid:mocks.0.id}}',",
" '{{uuid:generated_0}}',",
" 'update',",
" 'create',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000'",
")"
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"id\": \"{{uuid:mocks.0.id}}\",",
" \"type\": \"person\",",
" \"first_name\": \"NewFirst\",",
" \"last_name\": \"NewLast\",",
" \"id\": \"{{uuid:mocks.0.id}}\",",
" \"type\": \"person\",",
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"created_at\": \"{{timestamp}}\",",
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"modified_at\": \"{{timestamp}}\"",
" },",
@ -1631,10 +1858,6 @@
" \"first_name\": \"NewFirst\",",
" \"last_name\": \"NewLast\",",
" \"type\": \"person\"",
" },",
" \"old\": {",
" \"first_name\": \"OldFirst\",",
" \"last_name\": \"OldLast\"",
" }",
"}'))"
]
@ -1658,10 +1881,10 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
"FROM agreego.\"person\" t1",
"JOIN agreego.\"user\" t2 ON ",
"JOIN agreego.\"organization\" t3 ON ",
"JOIN agreego.\"entity\" t4 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"organization\" t2 ON ",
"JOIN agreego.\"user\" t3 ON ",
"JOIN agreego.\"person\" t4 ON ",
"WHERE",
" t1.id = '123')"
],
@ -1749,6 +1972,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"first_name\": \"John\",",
" \"last_name\": \"Doe\",",
@ -1930,6 +2154,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"total\": 100.0,",
" \"id\": \"{{uuid:generated_3}}\",",
@ -1949,6 +2174,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"first_name\": \"Bob\",",
" \"last_name\": \"Smith\",",
@ -1994,8 +2220,8 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
"FROM agreego.\"order\" t1",
"JOIN agreego.\"entity\" t2 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"order\" t2 ON ",
"WHERE",
" t1.id = 'abc'",
" OR (\"id\" = 'abc'))"
@ -2114,6 +2340,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"total\": 99.0,",
" \"id\": \"abc\",",
@ -2131,6 +2358,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"product\": \"Widget\",",
" \"price\": 99.0,",
@ -2619,6 +2847,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"first_name\": \"Relation\",",
" \"last_name\": \"Test\",",
@ -2638,6 +2867,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"is_primary\": true,",
" \"source_id\": \"{{uuid:generated_0}}\",",
@ -2663,6 +2893,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"number\": \"555-0001\",",
" \"id\": \"{{uuid:generated_1}}\",",
@ -2680,6 +2911,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"is_primary\": false,",
" \"source_id\": \"{{uuid:generated_0}}\",",
@ -2705,6 +2937,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"address\": \"test@example.com\",",
" \"id\": \"{{uuid:generated_5}}\",",
@ -2722,6 +2955,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"is_primary\": false,",
" \"source_id\": \"{{uuid:generated_0}}\",",
@ -2747,6 +2981,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"address\": \"test2@example.com\",",
" \"id\": \"{{uuid:generated_9}}\",",
@ -2788,20 +3023,62 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
"FROM agreego.\"person\" t1",
"JOIN agreego.\"user\" t2 ON ",
"JOIN agreego.\"organization\" t3 ON ",
"JOIN agreego.\"entity\" t4 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"organization\" t2 ON ",
"JOIN agreego.\"user\" t3 ON ",
"JOIN agreego.\"person\" t4 ON ",
"WHERE",
" t1.id = 'abc-archived')"
],
[
"UPDATE agreego.\"entity\" SET",
" archived = true,",
" modified_at = '{{timestamp}}',",
" modified_by = '00000000-0000-0000-0000-000000000000'",
"WHERE",
" id = 'abc-archived'"
"INSERT INTO agreego.\"entity\" (",
" \"archived\",",
" \"created_at\",",
" \"created_by\",",
" \"id\",",
" \"modified_at\",",
" \"modified_by\",",
" \"type\"",
")",
"VALUES (",
" true,",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" 'abc-archived',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"organization\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" 'abc-archived',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"user\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" 'abc-archived',",
" 'person'",
")"
],
[
"INSERT INTO agreego.\"person\" (",
" \"id\",",
" \"type\"",
")",
"VALUES (",
" 'abc-archived',",
" 'person'",
")"
],
[
"INSERT INTO agreego.change (",
@ -2814,37 +3091,33 @@
" \"modified_by\"",
")",
"VALUES (",
" '{",
" \"archived\": false",
" }',",
" NULL,",
" '{",
" \"archived\": true,",
" \"type\": \"person\"",
" }',",
" 'abc-archived',",
" '{{uuid:generated_0}}',",
" 'delete',",
" 'create',",
" '{{timestamp}}',",
" '00000000-0000-0000-0000-000000000000'",
")"
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"archived\": true,",
" \"id\": \"abc-archived\",",
" \"type\": \"person\",",
" \"first_name\": \"ArchivedFirst\",",
" \"last_name\": \"ArchivedLast\",",
" \"archived\": true,",
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"created_at\": \"{{timestamp}}\",",
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
" \"modified_at\": \"{{timestamp}}\"",
" },",
" \"new\": {",
" \"archived\": true,",
" \"type\": \"person\"",
" },",
" \"old\": {",
" \"archived\": false",
" }",
"}'))"
]
@ -2943,6 +3216,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"flags\": [",
" \"urgent\",",
@ -3058,6 +3332,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"product\": \"Widget\",",
" \"price\": 99.0,",
@ -3101,8 +3376,8 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
"FROM agreego.\"order_line\" t1",
"JOIN agreego.\"entity\" t2 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"order_line\" t2 ON ",
"WHERE",
" t1.id = '{{uuid:data.lines.0.id}}')"
],
@ -3167,6 +3442,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"product\": \"Widget\",",
" \"price\": 99.0,",
@ -3224,8 +3500,8 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
"FROM agreego.\"invoice\" t1",
"JOIN agreego.\"entity\" t2 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"invoice\" t2 ON ",
"WHERE",
" t1.id = '{{uuid:data.id}}'",
" OR (\"id\" = '{{uuid:data.id}}'))"
@ -3341,8 +3617,8 @@
"sql": [
[
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
"FROM agreego.\"account\" t1",
"JOIN agreego.\"entity\" t2 ON ",
"FROM agreego.\"entity\" t1",
"JOIN agreego.\"account\" t2 ON ",
"WHERE",
" t1.id = '{{uuid:data.id}}')"
],
@ -3404,6 +3680,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"kind\": \"checking\",",
" \"routing_number\": \"123456789\",",
@ -3698,6 +3975,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"organization_id\": \"parent-org-id\",",
" \"id\": \"{{uuid:generated_3}}\",",
@ -3717,6 +3995,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"first_name\": \"Const\",",
" \"last_name\": \"Person\",",
@ -3738,6 +4017,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"order_id\": \"{{uuid:generated_3}}\",",
" \"id\": \"{{uuid:generated_4}}\",",
@ -3757,6 +4037,7 @@
],
[
"(SELECT pg_notify('entity', '{",
" \"kind\": \"create\",",
" \"complete\": {",
" \"organization_id\": \"explicit-org-id\",",
" \"order_id\": \"{{uuid:generated_3}}\",",

File diff suppressed because it is too large Load Diff

View File

@ -159,7 +159,9 @@ impl Schema {
},
"null" => None,
custom => {
if db.enums.contains_key(custom) {
if custom.ends_with(".condition") || custom.ends_with(".filter") {
Some(vec![custom.to_string()])
} else if db.enums.contains_key(custom) {
Some(vec![format!("{}.condition", custom)])
} else {
// Assume anything else is a Relational cross-boundary that already has its own .filter dynamically built

View File

@ -85,7 +85,6 @@ impl DatabaseExecutor for MockExecutor {
Ok("2026-03-10T00:00:00Z".to_string())
}
#[cfg(test)]
fn get_queries(&self) -> Vec<String> {
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
fn timestamp(&self) -> Result<String, String>;
#[cfg(test)]
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,
) -> Result<Value, String> {
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) => {
if let Some(options) = schema.obj.compiled_options.get() {
if let Some(disc) = schema.obj.compiled_discriminator.get() {
@ -210,7 +212,13 @@ impl Merger {
let mut resolved_items = Vec::new();
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);
}
Ok(Value::Array(resolved_items))
@ -340,7 +348,10 @@ impl Merger {
if let Some(relation) = self.db.relations.get(&edge.constraint) {
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 {
let mut merged_relative = match self.merge_internal(
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();
for relative_item_val in relative_arr {
if let Value::Object(mut relative_item) = relative_item_val {
@ -574,7 +588,7 @@ impl Merger {
.and_then(|v| v.as_str())
.unwrap_or("");
let id_val = if entity_id.is_empty() {
Value::String(uuid::Uuid::new_v4().to_string())
Value::String(uuid::Uuid::now_v7().to_string())
} else {
Value::String(entity_id.to_string())
};
@ -777,13 +791,8 @@ impl Merger {
}
};
let mut execute_order: Vec<String> = entity_type.hierarchy.clone();
if change_kind == "create" {
execute_order.reverse();
}
for table_name in execute_order {
let table_fields = match grouped_fields.get(&table_name).and_then(|v| v.as_array()) {
for table_name in &entity_type.hierarchy {
let table_fields = match grouped_fields.get(table_name).and_then(|v| v.as_array()) {
Some(arr) => arr
.iter()
.filter_map(|v| v.as_str().map(|s| s.to_string()))
@ -946,9 +955,8 @@ impl Merger {
Value::Object(old_vals)
};
let entity_type_name = type_name.as_str().unwrap_or(&type_obj.name);
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("new".to_string(), new_val_obj.clone());
@ -963,15 +971,14 @@ impl Merger {
let mut notify_sql = None;
if type_obj.historical && change_kind != "replace" {
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(&new_val_obj),
Self::quote_literal(id_str),
Self::quote_literal(&Value::String(uuid::Uuid::new_v4().to_string())),
Self::quote_literal(&Value::String(uuid::Uuid::now_v7().to_string())),
Self::quote_literal(&Value::String(change_kind.to_string())),
Self::quote_literal(&Value::String(timestamp.to_string())),
Self::quote_literal(&Value::String(user_id.to_string())),
Self::quote_literal(&Value::String(entity_type_name.to_string()))
Self::quote_literal(&Value::String(user_id.to_string()))
);
self.db.execute(&change_sql, None)?;

View File

@ -44,7 +44,7 @@ fn test_library_api() {
{
"name": "source_schema",
"variations": ["source_schema"],
"hierarchy": ["source_schema", "entity"],
"hierarchy": ["entity", "source_schema"],
"schemas": {
"source_schema": {
"type": "object",
@ -60,7 +60,7 @@ fn test_library_api() {
{
"name": "target_schema",
"variations": ["target_schema"],
"hierarchy": ["target_schema", "entity"],
"hierarchy": ["entity", "target_schema"],
"schemas": {
"target_schema": {
"type": "object",
@ -109,7 +109,7 @@ fn test_library_api() {
"field_types": null,
"fields": [],
"grouped_fields": null,
"hierarchy": ["source_schema", "entity"],
"hierarchy": ["entity", "source_schema"],
"historical": false,
"id": "",
"longevity": null,
@ -174,7 +174,7 @@ fn test_library_api() {
"field_types": null,
"fields": [],
"grouped_fields": null,
"hierarchy": ["target_schema", "entity"],
"hierarchy": ["entity", "target_schema"],
"historical": false,
"id": "",
"longevity": null,

View File

@ -96,8 +96,10 @@ impl Case {
let queries = db.executor.get_queries();
if std::env::var("UPDATE_EXPECT").is_ok() {
crate::tests::runner::update_sql_fixture(path, suite_idx, case_idx, &queries);
Ok(())
} else {
expect.assert_sql(&queries)
}
expect.assert_sql(&queries)
} else {
Ok(())
}
@ -128,8 +130,10 @@ impl Case {
let queries = db.executor.get_queries();
if std::env::var("UPDATE_EXPECT").is_ok() {
crate::tests::runner::update_sql_fixture(path, suite_idx, case_idx, &queries);
Ok(())
} else {
expect.assert_sql(&queries)
}
expect.assert_sql(&queries)
} else {
Ok(())
}

View File

@ -1,4 +1,3 @@
pub mod pattern;
pub mod sql;
pub mod drop;
pub mod schema;

View File

@ -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(&regex::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(())
}
}

View File

@ -1,8 +1,9 @@
use super::Expect;
use regex::Regex;
use sqlparser::ast::{Expr, Query, SelectItem, Statement, TableFactor};
use sqlparser::dialect::PostgreSqlDialect;
use sqlparser::parser::Parser;
use std::collections::HashSet;
use std::collections::{HashMap, HashSet};
impl Expect {
pub fn assert_sql(&self, actual: &[String]) -> Result<(), String> {
@ -11,6 +12,7 @@ impl Expect {
return Err(e);
}
}
self.assert_pattern(actual)?;
Ok(())
}
@ -203,4 +205,132 @@ impl Expect {
}
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(&regex::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(())
}
}

View File

@ -1 +1 @@
1.0.155
1.0.159