summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-12-01 11:13:01 +0100
committerClaude Paroz <claude@2xlibre.net>2014-12-02 09:02:54 +0100
commit3a42d9730cbb07ffbb983791e631f5d0a6746f68 (patch)
tree79d5d29198c335f398fb1c17a634ce04ea992700 /tests
parentbc5bb3e1a0fd8e4641eafa263e6e5871198fbff4 (diff)
[1.7.x] Fixed #23909 -- Prevented crash when collecting SQL for RunSQL
Thanks James Rivett-Carnac for the report and Markus Holtermann for the review. Backport of e11c6fd21 from master.
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_operations.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 05e0f22696..5f4dc553a2 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -1219,6 +1219,12 @@ class OperationTests(OperationTestBase):
self.assertEqual(len(new_state.models["test_runsql", "somethingelse"].fields), 1)
# Make sure there's no table
self.assertTableNotExists("i_love_ponies")
+ # Test SQL collection
+ with connection.schema_editor(collect_sql=True) as editor:
+ operation.database_forwards("test_runsql", editor, project_state, new_state)
+ self.assertIn("LIKE '%%ponies';", "\n".join(editor.collected_sql))
+ operation.database_backwards("test_runsql", editor, project_state, new_state)
+ self.assertIn("LIKE '%%Ponies%%';", "\n".join(editor.collected_sql))
# Test the database alteration
with connection.schema_editor() as editor:
operation.database_forwards("test_runsql", editor, project_state, new_state)