Skip to content

Commit

Permalink
Merge pull request #151 from nicholasyager/nicholasyager-fix/require_…
Browse files Browse the repository at this point in the history
…version_formatting

Fix: `require-dbt-versions` no longer serialized as a list of characters
  • Loading branch information
dave-connors-3 authored Aug 28, 2023
2 parents 83bd564 + 07eccf5 commit 283d64e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 9 additions & 1 deletion dbt_meshify/storage/dbt_project_editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 6 additions & 7 deletions test-projects/split/split_proj/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() }}"
Expand All @@ -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
# +schema: jaffle_raw

0 comments on commit 283d64e

Please sign in to comment.