diff --git a/dbt_meshify/storage/dbt_project_editors.py b/dbt_meshify/storage/dbt_project_editors.py index 06bfa23..ecea8ba 100644 --- a/dbt_meshify/storage/dbt_project_editors.py +++ b/dbt_meshify/storage/dbt_project_editors.py @@ -94,7 +94,15 @@ 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. 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: + 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, entity_type=EntityType.Code, 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