From e6bb2a98e9a8765d5cb9718940eb9bb368adf666 Mon Sep 17 00:00:00 2001 From: Chris Jenkins Date: Tue, 1 Nov 2022 20:45:18 +1300 Subject: [PATCH] Include snapshots in match for fk model names --- macros/create_constraints.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/macros/create_constraints.sql b/macros/create_constraints.sql index f53d310..0f1242e 100644 --- a/macros/create_constraints.sql +++ b/macros/create_constraints.sql @@ -245,12 +245,12 @@ {%- set fk_model = none -%} {%- set pk_model = none -%} - {%- set fk_model_names = modules.re.findall( "models\W+(\w+)" , test_model.file_key_name) -%} + {%- set fk_model_names = modules.re.findall( "(models|snapshots)\W+(\w+)" , test_model.file_key_name) -%} {%- set fk_source_names = modules.re.findall( "source\W+(\w+)\W+(\w+)" , test_parameters.model) -%} {%- if 1 == fk_model_names | count -%} - {%- set fk_model = table_models | selectattr("name", "equalto", fk_model_names[0]) | first -%} - {%- set pk_model = table_models | rejectattr("name", "equalto", fk_model_names[0]) | first -%} + {%- set fk_model = table_models | selectattr("name", "equalto", fk_model_names[0][1]) | first -%} + {%- set pk_model = table_models | rejectattr("name", "equalto", fk_model_names[0][1]) | first -%} {%- elif 1 == fk_source_names | count -%} {%- if table_models[0].source_name == fk_source_names[0][0] and table_models[0].name == fk_source_names[0][1] -%} {%- set fk_model = table_models[0] -%}