Skip to content

Commit

Permalink
Fix regression in semver comparison logic (#7040) (#7041)
Browse files Browse the repository at this point in the history
(cherry picked from commit 915585c)

Co-authored-by: Jeremy Cohen <[email protected]>
  • Loading branch information
2 people authored and gshank committed Sep 8, 2024
1 parent 98f76f1 commit 8e47dc2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230224-001338.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix semver comparison logic by ensuring numeric values
time: 2023-02-24T00:13:38.23242+01:00
custom:
Author: jtcohen6
Issue: "7039"
4 changes: 2 additions & 2 deletions core/dbt/semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def compare(self, other):
# else is equal and will fall through

else: # major/minor/patch, should all be numbers
if a > b:
if int(a) > int(b):
return 1
elif a < b:
elif int(a) < int(b):
return -1
# else is equal and will fall through

Expand Down
8 changes: 8 additions & 0 deletions test/unit/test_semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ def test__resolve_to_specific_version(self):
['1.0.0', '1.1.0a1', '1.1.0', '1.2.0a1', '1.2.0']),
'1.1.0')

self.assertEqual(
resolve_to_specific_version(
# https://github.com/dbt-labs/dbt-core/issues/7039
# 10 is greater than 9
create_range('>0.9.0', '<0.10.0'),
['0.9.0', '0.9.1', '0.10.0']),
'0.9.1')

def test__filter_installable(self):
installable = filter_installable(
['1.1.0', '1.2.0a1', '1.0.0','2.1.0-alpha','2.2.0asdf','2.1.0','2.2.0','2.2.0-fishtown-beta','2.2.0-2'],
Expand Down

0 comments on commit 8e47dc2

Please sign in to comment.