From e581856ac93c2eb1059fd5763a5754bd9a8b05d8 Mon Sep 17 00:00:00 2001 From: Vilsol Date: Sat, 19 Feb 2022 19:33:11 +0200 Subject: [PATCH] fix: correct sql grouping --- db/postgres/version.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/db/postgres/version.go b/db/postgres/version.go index 31e1ff12..4cff8efa 100644 --- a/db/postgres/version.go +++ b/db/postgres/version.go @@ -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 {