Commit bc04fb16 authored by Nathan/Eilisha Shiraini's avatar Nathan/Eilisha Shiraini
Browse files

Fixing empty data lists

parent 230dd10f
Pipeline #506 passed with stages
in 3 minutes and 12 seconds
......@@ -36,14 +36,18 @@ class EnumDeleteOp(MigrateOperation):
@Operations.implementation_for(EnumInsertOp)
def insert(operations, operation):
if not operation.data:
return
values = ', '.join("('" + v + "')" for v in operation.data)
txt = 'INSERT INTO {tn} (item_id) VALUES {vl};'.format(tn = operation.tablename, vl = values)
txt = 'INSERT INTO {tn} (item_id) VALUES {vl}'.format(tn = operation.tablename, vl = values)
operations.execute(txt)
@Operations.implementation_for(EnumDeleteOp)
def delete(operations, operation):
if not operation.data:
return
values = ', '.join("'" + v + "'" for v in operation.data)
txt = 'DELETE FROM {tn} WHERE item_id IN ({vl});'.format(tn = operation.tablename, vl = values)
txt = 'DELETE FROM {tn} WHERE item_id IN ({vl})'.format(tn = operation.tablename, vl = values)
operations.execute(txt)
@alembic.autogenerate.render.renderers.dispatch_for(EnumInsertOp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment