Skip to content

Commit

Permalink
[Backport 1.7.latest] Fix #8836: Add version to fqn when version==0 (#…
Browse files Browse the repository at this point in the history
…8922)

Co-authored-by: Kshitij Aranke <[email protected]>
  • Loading branch information
github-actions[bot] and aranke authored Oct 26, 2023
1 parent 12c1cbb commit 5e13698
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20231026-002536.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Add version to fqn when version==0
time: 2023-10-26T00:25:36.259356-05:00
custom:
Author: aranke
Issue: "8836"
3 changes: 2 additions & 1 deletion core/dbt/contracts/graph/node_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def unique_id(self) -> str:
@property
def fqn(self) -> List[str]:
fqn = [self.package_name, self.name]
if self.version:
# Test for None explicitly because version can be 0
if self.version is not None:
fqn.append(f"v{self.version}")

return fqn
14 changes: 12 additions & 2 deletions tests/unit/test_contracts_graph_node_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_model_node_args_unique_id_with_version(self) -> None:
package_name="package",
identifier="identifier",
schema="schema",
version="1",
version=1,
)
assert model_node_args.unique_id == "model.package.name.v1"

Expand All @@ -33,6 +33,16 @@ def test_model_node_args_fqn_with_version(self) -> None:
package_name="package",
identifier="identifier",
schema="schema",
version="1",
version=1,
)
assert model_node_args.fqn == ["package", "name", "v1"]

def test_model_node_args_fqn_with_version_zero(self) -> None:
model_node_args = ModelNodeArgs(
name="name",
package_name="package",
identifier="identifier",
schema="schema",
version=0,
)
assert model_node_args.fqn == ["package", "name", "v0"]

0 comments on commit 5e13698

Please sign in to comment.