diff --git a/.changes/unreleased/Fixes-20230526-164727.yaml b/.changes/unreleased/Fixes-20230526-164727.yaml new file mode 100644 index 00000000000..20eb43b908f --- /dev/null +++ b/.changes/unreleased/Fixes-20230526-164727.yaml @@ -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" diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 3f4f3adec2c..5edc3f44db7 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -204,7 +204,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( diff --git a/tests/functional/graph_selection/test_version_selection.py b/tests/functional/graph_selection/test_version_selection.py index 6a122eae48b..4f9325a1fb8 100644 --- a/tests/functional/graph_selection/test_version_selection.py +++ b/tests/functional/graph_selection/test_version_selection.py @@ -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