summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorMarkus Holtermann <info@markusholtermann.eu>2015-01-08 18:00:04 +0100
committerTim Graham <timograham@gmail.com>2015-01-09 10:31:32 -0500
commitc8bac4b556cf4716dc9003e5da48060cb72ba7cb (patch)
tree8d75e220aa544e30a3b7582ff26fa701562437b4 /django/db
parent67d6a8c4e66c379111d0acf4552e162356917dd7 (diff)
Fixed #24098 -- Added no-op attributes to RunPython and RunSQL
Thanks Loïc Bistuer and Tim Graham for the discussion and review.
Diffstat (limited to 'django/db')
-rw-r--r--django/db/migrations/operations/special.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/django/db/migrations/operations/special.py b/django/db/migrations/operations/special.py
index 96fd2cc63c..00caa08684 100644
--- a/django/db/migrations/operations/special.py
+++ b/django/db/migrations/operations/special.py
@@ -61,6 +61,7 @@ class RunSQL(Operation):
Also accepts a list of operations that represent the state change effected
by this SQL change, in case it's custom column/table creation/deletion.
"""
+ noop = ''
def __init__(self, sql, reverse_sql=None, state_operations=None):
self.sql = sql
@@ -100,9 +101,9 @@ class RunSQL(Operation):
def describe(self):
return "Raw SQL operation"
- def _run_sql(self, schema_editor, sql):
- if isinstance(sql, (list, tuple)):
- for sql in sql:
+ def _run_sql(self, schema_editor, sqls):
+ if isinstance(sqls, (list, tuple)):
+ for sql in sqls:
params = None
if isinstance(sql, (list, tuple)):
elements = len(sql)
@@ -111,8 +112,8 @@ class RunSQL(Operation):
else:
raise ValueError("Expected a 2-tuple but got %d" % elements)
schema_editor.execute(sql, params=params)
- else:
- statements = schema_editor.connection.ops.prepare_sql_script(sql)
+ elif sqls != RunSQL.noop:
+ statements = schema_editor.connection.ops.prepare_sql_script(sqls)
for statement in statements:
schema_editor.execute(statement, params=None)
@@ -175,3 +176,7 @@ class RunPython(Operation):
def describe(self):
return "Raw Python operation"
+
+ @staticmethod
+ def noop(apps, schema_editor):
+ return None