From eab71f7690c523b25b867a9cd5bf6fb82a33c6b4 Mon Sep 17 00:00:00 2001 From: Hannes Ljungberg Date: Mon, 26 Apr 2021 13:51:10 +0200 Subject: [PATCH] Fixed #32686 -- Removed unnecessary semicolon on collected multiline SQL for RunSQL. --- django/db/backends/base/schema.py | 2 +- tests/migrations/test_operations.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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: