From 3c220cd3517f11beb48497fb47066abe248f0b38 Mon Sep 17 00:00:00 2001 From: Drew Banin Date: Mon, 20 Jan 2020 18:41:09 -0500 Subject: [PATCH] (#2049) Fix for clobber config fields which were errantly extended --- core/dbt/source_config.py | 6 ++++++ test/unit/test_source_config.py | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/core/dbt/source_config.py b/core/dbt/source_config.py index dd1efa00bdb..61d3da9bdcb 100644 --- a/core/dbt/source_config.py +++ b/core/dbt/source_config.py @@ -50,9 +50,15 @@ def __init__(self, active_project, own_project, fqn, node_type): def _merge(self, *configs): merged_config = {} for config in configs: + # Do not attempt to deep merge clobber fields + clobber = { + key: config.pop(key) for key in list(config.keys()) + if key in (self.ClobberFields | self.AdapterSpecificConfigs) + } intermediary_merged = deep_merge( merged_config.copy(), config.copy() ) + intermediary_merged.update(clobber) merged_config.update(intermediary_merged) return merged_config diff --git a/test/unit/test_source_config.py b/test/unit/test_source_config.py index 82e0547ebcd..25147f7c131 100644 --- a/test/unit/test_source_config.py +++ b/test/unit/test_source_config.py @@ -120,6 +120,28 @@ def test__source_config_multiple_calls(self): } self.assertEqual(cfg.config, expect) + def test__source_config_merge(self): + self.root_project_config.models = {'sort': ['a', 'b']} + cfg = SourceConfig(self.root_project_config, self.root_project_config, + ['root', 'x'], NodeType.Model) + cfg.update_in_model_config({ + 'materialized': 'something', + 'sort': ['d', 'e'] + }) + expect = { + 'column_types': {}, + 'enabled': True, + 'materialized': 'something', + 'post-hook': [], + 'pre-hook': [], + 'persist_docs': {}, + 'quoting': {}, + 'sort': ['d', 'e'], + 'tags': [], + 'vars': {}, + } + self.assertEqual(cfg.config, expect) + def test_source_config_all_keys_accounted_for(self): used_keys = frozenset(SourceConfig.AppendListFields) | \ frozenset(SourceConfig.ExtendDictFields) | \