Skip to content

Commit

Permalink
Merge pull request #12422 from PennyDreadfulMTG/fixes
Browse files Browse the repository at this point in the history
Fix preferred printing
  • Loading branch information
mergify[bot] committed May 2, 2024
2 parents 1980568 + c83de4b commit b5b8f97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion find/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def parse_criterion(key: Token, operator: Token, term: Token) -> str:
return rarity_where(operator.value(), term.value())
if key.value() == 'mana' or key.value() == 'm':
return mana_where(operator.value(), term.value())
if key.value() == 'is':
if key.value() == 'is' or key.value() == 'has':
return is_subquery(term.value())
if key.value() == 'not':
return f'NOT ({is_subquery(term.value())})'
Expand Down
12 changes: 7 additions & 5 deletions magic/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ def get_printing(generalized_card: Card, setcode: str) -> Printing | None:
sql = 'SELECT ' + (', '.join('p.' + property for property in card.printing_properties())) + ', s.code AS set_code' \
+ ' FROM printing AS p' \
+ ' LEFT OUTER JOIN `set` AS s ON p.set_id = s.id' \
+ f' WHERE card_id = %s AND (s.code = %s OR s.name LIKE {sqllikeescape(setcode)})'
rs = db().select(sql, [generalized_card.id, setcode])
if rs:
return [Printing(r) for r in rs][0]
return None
+ f' WHERE card_id = %s AND (s.code = %s OR s.name LIKE {sqllikeescape(setcode)})' \
+ ' ORDER BY s.code = %s DESC, s.released_at' \
+ ' LIMIT 1'
rs = db().select(sql, [generalized_card.id, setcode, setcode])
if not rs:
return None
return Printing(rs[0])

def get_set(set_id: int) -> Container:
rs = db().select('SELECT ' + (', '.join(property for property in card.set_properties())) + ' FROM `set` WHERE id = %s', [set_id])
Expand Down

0 comments on commit b5b8f97

Please sign in to comment.