Loading django/core/management/sql.py +0 −18 Original line number Diff line number Diff line from __future__ import unicode_literals import re from django.apps import apps from django.core.management.base import CommandError from django.db import models, router Loading Loading @@ -168,22 +166,6 @@ def sql_all(app_config, style, connection): ) def _split_statements(content): # Private API only called from code that emits a RemovedInDjango19Warning. comment_re = re.compile(r"^((?:'[^']*'|[^'])*?)--.*$") statements = [] statement = [] for line in content.split("\n"): cleaned_line = comment_re.sub(r"\1", line).strip() if not cleaned_line: continue statement.append(cleaned_line) if cleaned_line.endswith(";"): statements.append(" ".join(statement)) statement = [] return statements def emit_pre_migrate_signal(verbosity, interactive, db): # Emit the pre_migrate signal for every application. for app_config in apps.get_app_configs(): Loading django/db/backends/base/operations.py +6 −15 Original line number Diff line number Diff line import datetime import decimal from importlib import import_module import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db.backends import utils from django.utils import six, timezone from django.utils.dateparse import parse_duration from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import force_text Loading Loading @@ -255,7 +254,7 @@ class BaseDatabaseOperations(object): """ return 'DEFAULT' def prepare_sql_script(self, sql, _allow_fallback=False): def prepare_sql_script(self, sql): """ Takes a SQL script that may contain multiple lines and returns a list of statements to feed to successive cursor.execute() calls. Loading @@ -264,21 +263,13 @@ class BaseDatabaseOperations(object): cursor.execute() call and PEP 249 doesn't talk about this use case, the default implementation is conservative. """ # Remove _allow_fallback and keep only 'return ...' in Django 1.9. try: # This import must stay inside the method because it's optional. import sqlparse except ImportError: if _allow_fallback: # Without sqlparse, fall back to the legacy (and buggy) logic. warnings.warn( "Providing initial SQL data on a %s database will require " "sqlparse in Django 1.9." % self.connection.vendor, RemovedInDjango19Warning) from django.core.management.sql import _split_statements return _split_statements(sql) else: raise raise ImproperlyConfigured( "sqlparse is required if you don't split your SQL " "statements manually." ) else: return [sqlparse.format(statement, strip_comments=True) for statement in sqlparse.split(sql) if statement] Loading django/db/backends/postgresql_psycopg2/operations.py +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ class DatabaseOperations(BaseDatabaseOperations): def no_limit_value(self): return None def prepare_sql_script(self, sql, _allow_fallback=False): def prepare_sql_script(self, sql): return [sql] def quote_name(self, name): Loading Loading
django/core/management/sql.py +0 −18 Original line number Diff line number Diff line from __future__ import unicode_literals import re from django.apps import apps from django.core.management.base import CommandError from django.db import models, router Loading Loading @@ -168,22 +166,6 @@ def sql_all(app_config, style, connection): ) def _split_statements(content): # Private API only called from code that emits a RemovedInDjango19Warning. comment_re = re.compile(r"^((?:'[^']*'|[^'])*?)--.*$") statements = [] statement = [] for line in content.split("\n"): cleaned_line = comment_re.sub(r"\1", line).strip() if not cleaned_line: continue statement.append(cleaned_line) if cleaned_line.endswith(";"): statements.append(" ".join(statement)) statement = [] return statements def emit_pre_migrate_signal(verbosity, interactive, db): # Emit the pre_migrate signal for every application. for app_config in apps.get_app_configs(): Loading
django/db/backends/base/operations.py +6 −15 Original line number Diff line number Diff line import datetime import decimal from importlib import import_module import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db.backends import utils from django.utils import six, timezone from django.utils.dateparse import parse_duration from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import force_text Loading Loading @@ -255,7 +254,7 @@ class BaseDatabaseOperations(object): """ return 'DEFAULT' def prepare_sql_script(self, sql, _allow_fallback=False): def prepare_sql_script(self, sql): """ Takes a SQL script that may contain multiple lines and returns a list of statements to feed to successive cursor.execute() calls. Loading @@ -264,21 +263,13 @@ class BaseDatabaseOperations(object): cursor.execute() call and PEP 249 doesn't talk about this use case, the default implementation is conservative. """ # Remove _allow_fallback and keep only 'return ...' in Django 1.9. try: # This import must stay inside the method because it's optional. import sqlparse except ImportError: if _allow_fallback: # Without sqlparse, fall back to the legacy (and buggy) logic. warnings.warn( "Providing initial SQL data on a %s database will require " "sqlparse in Django 1.9." % self.connection.vendor, RemovedInDjango19Warning) from django.core.management.sql import _split_statements return _split_statements(sql) else: raise raise ImproperlyConfigured( "sqlparse is required if you don't split your SQL " "statements manually." ) else: return [sqlparse.format(statement, strip_comments=True) for statement in sqlparse.split(sql) if statement] Loading
django/db/backends/postgresql_psycopg2/operations.py +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ class DatabaseOperations(BaseDatabaseOperations): def no_limit_value(self): return None def prepare_sql_script(self, sql, _allow_fallback=False): def prepare_sql_script(self, sql): return [sql] def quote_name(self, name): Loading