Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: require-dbt-versions no longer serialized as a list of characters #151

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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