diff options
| author | Hannes Ljungberg <hannes.ljungberg@gmail.com> | 2021-04-26 13:51:10 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-04-27 08:01:07 +0200 |
| commit | eab71f7690c523b25b867a9cd5bf6fb82a33c6b4 (patch) | |
| tree | 9f83644869ff6291e572cc703db53069b06352ad | |
| parent | 95754dbc9b9479787e422f32b028493a4d2a6ec1 (diff) | |
Fixed #32686 -- Removed unnecessary semicolon on collected multiline SQL for RunSQL.
| -rw-r--r-- | django/db/backends/base/schema.py | 2 | ||||
| -rw-r--r-- | tests/migrations/test_operations.py | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index ef915c311b..4998a3fe2e 100644 --- a/django/db/backends/base/schema.py +++ b/django/db/backends/base/schema.py @@ -135,7 +135,7 @@ class BaseDatabaseSchemaEditor: # Log the command we're running, then run it logger.debug("%s; (params %r)", sql, params, extra={'params': params, 'sql': sql}) if self.collect_sql: - ending = "" if sql.endswith(";") else ";" + ending = "" if sql.rstrip().endswith(";") else ";" if params is not None: self.collected_sql.append((sql % tuple(map(self.quote_value, params))) + ending) else: diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index 3070aece2b..09c11e97db 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -3007,6 +3007,7 @@ class OperationTests(OperationTestBase): project_state = self.set_up_test_model('test_runsql') new_state = project_state.clone() tests = [ + 'INSERT INTO test_runsql_pony (pink, weight) VALUES (1, 1);\n', 'INSERT INTO test_runsql_pony (pink, weight) VALUES (1, 1)\n', ] for sql in tests: |
