From aed67b9e42b12915d104abb742436a23dd160e65 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 17 Jun 2012 16:32:28 +0200 Subject: [PATCH] only commit if we have data --- pandora/sequence/tasks.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandora/sequence/tasks.py b/pandora/sequence/tasks.py index a1ff5fd43..00a2bb045 100644 --- a/pandora/sequence/tasks.py +++ b/pandora/sequence/tasks.py @@ -42,11 +42,11 @@ def get_sequences(itemId): v = ', '.join([isinstance(v, basestring) and "'%s'"%v or str(v) for v in sequence.values()]) values.append('(%s)'%v) - - cursor = connection.cursor() - sql = "INSERT INTO sequence_sequence (%s) VALUES %s" % (keys, ', '.join(values)); - cursor.execute(sql) - transaction.commit_unless_managed() + if values: + cursor = connection.cursor() + sql = "INSERT INTO sequence_sequence (%s) VALUES %s" % (keys, ', '.join(values)); + cursor.execute(sql) + transaction.commit_unless_managed() @task(ignore_results=True, queue='encoding') def update_sequence_ids(itemId):