Skip to content

Commit

Permalink
Version 0 for model works for latest_version (#7712) (#7780)
Browse files Browse the repository at this point in the history
(cherry picked from commit 79bd985)

Co-authored-by: Gerda Shank <gerda@dbtlabs.com>
  • Loading branch information
github-actions[bot] and gshank authored Jun 8, 2023
1 parent d94d651 commit 467cae0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230526-164727.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Using version 0 works when resolving single model
time: 2023-05-26T16:47:27.6065-04:00
custom:
Author: gshank
Issue: "7372"
2 changes: 1 addition & 1 deletion core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def find(
if v.name == node.name and v.version is not None
]
)
assert node.latest_version # for mypy, whenever i may find it
assert node.latest_version is not None # for mypy, whenever i may find it
if max_version > UnparsedVersion(node.latest_version):
fire_event(
UnpinnedRefNewVersionAvailable(
Expand Down
22 changes: 22 additions & 0 deletions tests/functional/graph_selection/test_version_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,25 @@ def test_select_group_and_children_selector_str(self, project): # noqa
def test_select_models_two_versions(self, project):
results = run_dbt(["ls", "--models", "version:latest version:old"])
assert sorted(results) == ["test.versioned.v1", "test.versioned.v2"]


my_model_yml = """
models:
- name: my_model
versions:
- v: 0
"""


class TestVersionZero:
@pytest.fixture(scope="class")
def models(self):
return {
"my_model.sql": "select 1 as id",
"another.sql": "select * from {{ ref('my_model') }}",
"schema.yml": my_model_yml,
}

def test_version_zero(self, project):
results = run_dbt(["run"])
assert len(results) == 2

0 comments on commit 467cae0

Please sign in to comment.