mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #23909 -- Prevented crash when collecting SQL for RunSQL
Thanks James Rivett-Carnac for the report and Markus Holtermann for the review.
This commit is contained in:
parent
777b4c26e3
commit
e11c6fd218
3 changed files with 14 additions and 1 deletions
|
@ -1289,6 +1289,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue