Commit c1121983 authored by Conrad Kramer's avatar Conrad Kramer Committed by Tim Graham
Browse files

Fixed #26542 -- Fixed quoting in CreateExtension operation.

parent 8ccb8ff4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,10 +14,10 @@ class CreateExtension(Operation):
    def database_forwards(self, app_label, schema_editor, from_state, to_state):
        if schema_editor.connection.vendor != 'postgresql':
            return
        schema_editor.execute("CREATE EXTENSION IF NOT EXISTS %s" % self.name)
        schema_editor.execute("CREATE EXTENSION IF NOT EXISTS %s" % schema_editor.quote_name(self.name))

    def database_backwards(self, app_label, schema_editor, from_state, to_state):
        schema_editor.execute("DROP EXTENSION %s" % self.name)
        schema_editor.execute("DROP EXTENSION %s" % schema_editor.quote_name(self.name))

    def describe(self):
        return "Creates extension %s" % self.name
+5 −4
Original line number Diff line number Diff line
@@ -5,20 +5,21 @@ from django.db import migrations

try:
    from django.contrib.postgres.operations import (
        HStoreExtension, UnaccentExtension,
        CreateExtension, HStoreExtension, UnaccentExtension,
    )
except ImportError:
    from django.test import mock
    CreateExtension = mock.Mock()
    HStoreExtension = mock.Mock()
    UnaccentExtension = mock.Mock()


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        # Ensure CreateExtension quotes extension names by creating one with a
        # dash in its name.
        CreateExtension('uuid-ossp'),
        HStoreExtension(),
        UnaccentExtension(),
    ]