Added support for "IN" operator of a WHERE clause.
The table update only allowed for "==" operator as in: UPDATE mytable SET foo = 'bar' WHERE id = 123; Now allows for "IN" operator as in: UPDATE mytable SET foo = 'bar' WHERE id IN (123, 876); This required changes to the "_args_to_clause" and "update" functions.
This commit is contained in:
parent
4f3f574d58
commit
fffa633e84
@ -121,6 +121,13 @@ class Table(object):
|
||||
if not len(keys):
|
||||
return False
|
||||
clause = [(u, row.get(u)) for u in keys]
|
||||
"""
|
||||
Don't update the key itself, so remove any keys from the row dict
|
||||
"""
|
||||
for key in keys:
|
||||
if key in row.keys():
|
||||
del row[key]
|
||||
|
||||
if ensure:
|
||||
self._ensure_columns(row, types=types)
|
||||
try:
|
||||
@ -180,7 +187,10 @@ class Table(object):
|
||||
self._ensure_columns(args)
|
||||
clauses = []
|
||||
for k, v in args.items():
|
||||
clauses.append(self.table.c[k] == v)
|
||||
if isinstance(v, list) or isinstance(v, tuple):
|
||||
clauses.append(self.table.c[k].in_(v))
|
||||
else:
|
||||
clauses.append(self.table.c[k] == v)
|
||||
return and_(*clauses)
|
||||
|
||||
def create_column(self, name, type):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user