Skip to content

Commit

Permalink
(#2049) Fix for clobber config fields which were errantly extended
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbanin committed Jan 20, 2020
1 parent 66a4f76 commit 5c5ae43
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/dbt/source_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions test/unit/test_source_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) | \
Expand Down

0 comments on commit 5c5ae43

Please sign in to comment.