From 0e55c32d589def0b1d6022ed1dceb4f2de9796ce Mon Sep 17 00:00:00 2001 From: Nicholas Yager Date: Fri, 25 Aug 2023 08:38:51 -0400 Subject: [PATCH 1/2] fix: `require-dbt-versions` no longer serialized as a list of characters --- dbt_meshify/storage/dbt_project_editors.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dbt_meshify/storage/dbt_project_editors.py b/dbt_meshify/storage/dbt_project_editors.py index e49b715..8ac7e11 100644 --- a/dbt_meshify/storage/dbt_project_editors.py +++ b/dbt_meshify/storage/dbt_project_editors.py @@ -95,7 +95,11 @@ def write_project_file(self) -> FileChange: # this one appears in the project yml, but i don't think it should be written contents.pop("query-comment") contents = filter_empty_dict_items(contents) - # project_file_path = self.target_directory / Path("dbt_project.yml") + + # Serialize the `require-dbt-version` field into a string + if "require-dbt-version" in contents: + contents["require-dbt-version"] = "".join(contents["require-dbt-version"]) + return FileChange( operation=Operation.Add, entity_type=EntityType.Code, From 0f9ff90f065d378552e42d741015d3aaee908128 Mon Sep 17 00:00:00 2001 From: Nicholas Yager Date: Sat, 26 Aug 2023 18:09:51 -0400 Subject: [PATCH 2/2] fix: Update require-dbt-version to support actual lists of versions --- dbt_meshify/storage/dbt_project_editors.py | 8 ++++++-- test-projects/split/split_proj/dbt_project.yml | 13 ++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/dbt_meshify/storage/dbt_project_editors.py b/dbt_meshify/storage/dbt_project_editors.py index 8ac7e11..01fb044 100644 --- a/dbt_meshify/storage/dbt_project_editors.py +++ b/dbt_meshify/storage/dbt_project_editors.py @@ -96,9 +96,13 @@ def write_project_file(self) -> FileChange: contents.pop("query-comment") contents = filter_empty_dict_items(contents) - # Serialize the `require-dbt-version` field into a string + # Serialize the `require-dbt-version` field into a string. This happens because dbt is expecting a list of + # strings, but also accepts a singular string value, too. We can handle the latter case by checking the length + # of each item in the list. If they're all one character long, then we're really working with a single version + # string. if "require-dbt-version" in contents: - contents["require-dbt-version"] = "".join(contents["require-dbt-version"]) + if max([len(version) for version in contents["require-dbt-version"]]) == 1: + contents["require-dbt-version"] = "".join(contents["require-dbt-version"]) return FileChange( operation=Operation.Add, diff --git a/test-projects/split/split_proj/dbt_project.yml b/test-projects/split/split_proj/dbt_project.yml index 41196c4..da86d0a 100644 --- a/test-projects/split/split_proj/dbt_project.yml +++ b/test-projects/split/split_proj/dbt_project.yml @@ -1,13 +1,12 @@ - # Name your project! Project names should contain only lowercase characters # and underscores. A good package name should reflect your organization's # name or the intended use of these models -name: 'split_proj' -version: '1.0.0' +name: "split_proj" +version: "1.0.0" config-version: 2 # This setting configures which "profile" dbt uses for this project. -profile: 'split_proj' +profile: "split_proj" # These configurations specify where dbt should look for different types of files. # The `model-paths` config, for example, states that models in this project can be @@ -20,10 +19,11 @@ seed-paths: ["seeds", "jaffle_data"] macro-paths: ["macros"] snapshot-paths: ["snapshots"] -clean-targets: # directories to be removed by `dbt clean` +clean-targets: # directories to be removed by `dbt clean` - "target" - "dbt_packages" +require-dbt-version: [">=1.6.0", "<1.7.0"] vars: truncate_timespan_to: "{{ current_timestamp() }}" @@ -43,10 +43,9 @@ models: seeds: +schema: jaffle_raw - # the below config for seeds is only relevant when seeding the project for the fist time with the raw jaffle data # pont the seed path to the jaffle data directory and make sure this is uncommented # seeds: # split_proj: -# +schema: jaffle_raw \ No newline at end of file +# +schema: jaffle_raw