forked from LBRYCommunity/lbry-sdk
make sure SQL IN works with python set
This commit is contained in:
parent
98c60b38fc
commit
6b745c53dc
2 changed files with 2 additions and 2 deletions
|
@ -140,7 +140,7 @@ def constraints_to_sql(constraints, joiner=' AND ', prepend_key=''):
|
||||||
if constraint:
|
if constraint:
|
||||||
if isinstance(constraint, (list, set, tuple)):
|
if isinstance(constraint, (list, set, tuple)):
|
||||||
if len(constraint) == 1:
|
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}')
|
sql.append(f'{col} {one_val_op} :{key}{tag}')
|
||||||
else:
|
else:
|
||||||
keys = []
|
keys = []
|
||||||
|
|
|
@ -99,7 +99,7 @@ class TestQueryBuilder(unittest.TestCase):
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
self.assertTupleEqual(
|
self.assertTupleEqual(
|
||||||
constraints_to_sql({'txo.name__in': ('abc123',)}),
|
constraints_to_sql({'txo.name__in': {'abc123'}}),
|
||||||
('txo.name = :txo_name__in0', {
|
('txo.name = :txo_name__in0', {
|
||||||
'txo_name__in0': 'abc123',
|
'txo_name__in0': 'abc123',
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue