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 24, 2020
1 parent 1a72660 commit 1f74980
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/dbt/source_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ 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
config = config.copy()
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()
merged_config, config
)
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 1f74980

Please sign in to comment.