From 6b745c53dcddfaee22ec2b885b748df078ae78f7 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Wed, 12 Feb 2020 11:41:32 -0500 Subject: [PATCH] make sure SQL IN works with python set --- lbry/wallet/database.py | 2 +- tests/unit/wallet/test_database.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lbry/wallet/database.py b/lbry/wallet/database.py index ab4b9a402..415463e02 100644 --- a/lbry/wallet/database.py +++ b/lbry/wallet/database.py @@ -140,7 +140,7 @@ def constraints_to_sql(constraints, joiner=' AND ', prepend_key=''): if constraint: if isinstance(constraint, (list, set, tuple)): if len(constraint) == 1: - values[f'{key}{tag}'] = constraint[0] + values[f'{key}{tag}'] = next(iter(constraint)) sql.append(f'{col} {one_val_op} :{key}{tag}') else: keys = [] diff --git a/tests/unit/wallet/test_database.py b/tests/unit/wallet/test_database.py index 6b05d239e..29ef58b46 100644 --- a/tests/unit/wallet/test_database.py +++ b/tests/unit/wallet/test_database.py @@ -99,7 +99,7 @@ class TestQueryBuilder(unittest.TestCase): }) ) self.assertTupleEqual( - constraints_to_sql({'txo.name__in': ('abc123',)}), + constraints_to_sql({'txo.name__in': {'abc123'}}), ('txo.name = :txo_name__in0', { 'txo_name__in0': 'abc123', })