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

Fix regression in semver comparison logic #7040

Merged
merged 1 commit into from
Feb 23, 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-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