From c129864c894a5cfbe6135998e8da869151128e20 Mon Sep 17 00:00:00 2001 From: Alex Groleau Date: Wed, 13 May 2026 16:31:06 -0400 Subject: [PATCH] fixed another org id issue with merger --- fixtures/merger.json | 10 ++++++++++ src/merger/mod.rs | 16 ++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fixtures/merger.json b/fixtures/merger.json index 7957fb1..49d4fa3 100644 --- a/fixtures/merger.json +++ b/fixtures/merger.json @@ -1806,6 +1806,7 @@ " \"id\",", " \"modified_at\",", " \"modified_by\",", + " \"organization_id\",", " \"type\"", ")", "VALUES (", @@ -1814,6 +1815,7 @@ " '{{uuid:customer_id}}',", " '{{timestamp}}',", " '00000000-0000-0000-0000-000000000000',", + " 'ffffffff-ffff-ffff-ffff-ffffffffffff',", " 'person'", ")" ], @@ -1869,6 +1871,7 @@ " \"date_of_birth\":\"2000-01-01\",", " \"first_name\":\"Bob\",", " \"last_name\":\"Smith\",", + " \"organization_id\":\"ffffffff-ffff-ffff-ffff-ffffffffffff\",", " \"type\":\"person\"", " }',", " '{{uuid:customer_id}}',", @@ -1964,12 +1967,14 @@ " \"last_name\":\"Smith\",", " \"modified_at\":\"{{timestamp}}\",", " \"modified_by\":\"00000000-0000-0000-0000-000000000000\",", + " \"organization_id\":\"ffffffff-ffff-ffff-ffff-ffffffffffff\",", " \"type\":\"person\"", " },", " \"new\":{", " \"date_of_birth\":\"2000-01-01\",", " \"first_name\":\"Bob\",", " \"last_name\":\"Smith\",", + " \"organization_id\":\"ffffffff-ffff-ffff-ffff-ffffffffffff\",", " \"type\":\"person\"", " }", " }')" @@ -3368,6 +3373,7 @@ " \"id\",", " \"modified_at\",", " \"modified_by\",", + " \"organization_id\",", " \"type\"", ")", "VALUES (", @@ -3376,6 +3382,7 @@ " '{{uuid:person_id}}',", " '{{timestamp}}',", " '{{uuid}}',", + " 'ffffffff-ffff-ffff-ffff-ffffffffffff',", " 'person'", ")" ], @@ -3428,6 +3435,7 @@ " '{", " \"first_name\":\"Const\",", " \"last_name\":\"Person\",", + " \"organization_id\":\"ffffffff-ffff-ffff-ffff-ffffffffffff\",", " \"type\":\"person\"", " }',", " '{{uuid:person_id}}',", @@ -3634,11 +3642,13 @@ " \"last_name\":\"Person\",", " \"modified_at\":\"{{timestamp}}\",", " \"modified_by\":\"00000000-0000-0000-0000-000000000000\",", + " \"organization_id\":\"ffffffff-ffff-ffff-ffff-ffffffffffff\",", " \"type\":\"person\"", " },", " \"new\":{", " \"first_name\":\"Const\",", " \"last_name\":\"Person\",", + " \"organization_id\":\"ffffffff-ffff-ffff-ffff-ffffffffffff\",", " \"type\":\"person\"", " }", " }')" diff --git a/src/merger/mod.rs b/src/merger/mod.rs index 917d3cc..8b4bbf4 100644 --- a/src/merger/mod.rs +++ b/src/merger/mod.rs @@ -135,14 +135,18 @@ impl Merger { schema: &Arc, ) { if !relative.contains_key("organization_id") { - if let Some(org_id) = entity_fields.get("organization_id") { - if let Some(compiled_props) = schema.obj.compiled_properties.get() { - if let Some(org_schema) = compiled_props.get("organization_id") { - if org_schema.obj.const_.is_some() { - return; - } + let mut const_val: Option = None; + if let Some(compiled_props) = schema.obj.compiled_properties.get() { + if let Some(org_schema) = compiled_props.get("organization_id") { + if let Some(c) = &org_schema.obj.const_ { + const_val = Some(c.clone()); } } + } + + if let Some(c) = const_val { + relative.insert("organization_id".to_string(), c); + } else if let Some(org_id) = entity_fields.get("organization_id") { relative.insert("organization_id".to_string(), org_id.clone()); } }