From 1e635a4e631346434f7ea7aaa82525baebf2f63b Mon Sep 17 00:00:00 2001 From: Correl Date: Wed, 27 Jul 2022 22:14:00 -0400 Subject: [PATCH] Fix color less than or equal to --- tutor/database.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tutor/database.py b/tutor/database.py index 7e09df8..c9281f5 100644 --- a/tutor/database.py +++ b/tutor/database.py @@ -1,5 +1,6 @@ import datetime import decimal +import itertools import logging import typing import uuid @@ -123,7 +124,14 @@ async def advanced_search( constraints.append(f"cards.color_identity ILIKE %({param})s") params[param] = tutor.models.Color.to_string(criterion.colors) if criterion.operator == tutor.search.Operator.lte: - colors = list({str(color) for color in criterion.colors} | {""}) + colors = list( + { + tutor.models.Color.to_string(list(combo)) + for n in range(len(criterion.colors)) + for combo in itertools.combinations(criterion.colors, n + 1) + } + | {""} + ) constraints.append( "({})".format( " OR ".join(