Fixed #26542 -- Fixed quoting in CreateExtension operation.

This commit is contained in:
Conrad Kramer 2016-04-25 16:30:48 -07:00 committed by Tim Graham
parent 8ccb8ff453
commit c112198332
2 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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(),
]