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

[Backport 1.5.latest] Version 0 for model works for latest_version #7780

Merged
merged 3 commits into from
Jun 8, 2023
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
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