Skip to content

Commit

Permalink
fix: correct sql grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilsol committed Feb 19, 2022
1 parent c392da4 commit e581856
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions db/postgres/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,25 +328,25 @@ func GetModVersionsConstraint(ctx context.Context, modID string, constraint stri
sign := matches[0][1]
switch sign {
case "<=":
query = query.Where("version_major < ?", major).
query = query.Where(db.Or("version_major < ?", major).
Or("version_major = ? AND version_minor < ?", major, minor).
Or("version_major = ? AND version_minor = ? AND version_patch <= ?", major, minor, patch)
Or("version_major = ? AND version_minor = ? AND version_patch <= ?", major, minor, patch))
case "<":
query = query.Where("version_major < ?", major).
query = query.Where(db.Or("version_major < ?", major).
Or("version_major = ? AND version_minor < ?", major, minor).
Or("version_major = ? AND version_minor = ? AND version_patch < ?", major, minor, patch)
Or("version_major = ? AND version_minor = ? AND version_patch < ?", major, minor, patch))
case ">":
query = query.Where("version_major > ?", major).
query = query.Where(db.Or("version_major > ?", major).
Or("version_major = ? AND version_minor > ?", major, minor).
Or("version_major = ? AND version_minor = ? AND version_patch > ?", major, minor, patch)
Or("version_major = ? AND version_minor = ? AND version_patch > ?", major, minor, patch))
case ">=":
query = query.Where("version_major > ?", major).
query = query.Where(db.Or("version_major > ?", major).
Or("version_major = ? AND version_minor > ?", major, minor).
Or("version_major = ? AND version_minor = ? AND version_patch >= ?", major, minor, patch)
Or("version_major = ? AND version_minor = ? AND version_patch >= ?", major, minor, patch))
case "^":
if major != 0 {
query = query.Where("version_major = ? AND version_minor > ?", major, minor).
Or("version_major = ? AND version_minor = ? AND version_patch >= ?", major, minor, patch)
query = query.Where(db.Or("version_major = ? AND version_minor > ?", major, minor).
Or("version_major = ? AND version_minor = ? AND version_patch >= ?", major, minor, patch))
} else if minor != 0 {
query = query.Where("version_major = ? AND version_minor = ? AND version_patch >= ?", major, minor, patch)
} else {
Expand Down

0 comments on commit e581856

Please sign in to comment.