From 47d20cb5cfb8c4b68a926694154a59f7bc88c0f1 Mon Sep 17 00:00:00 2001 From: Jason Pellerin Date: Mon, 10 Jul 2006 19:40:32 +0000 Subject: [PATCH] [multi-db] Updated django.core.management.get_sql_initial_data to use each model's connection info. Removed unused style argument from builder.get_initialdata. git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3315 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 17 ++++++++++------- django/db/backends/ansi/sql.py | 4 +--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/django/core/management.py b/django/core/management.py index 985fdb3423..c9c07ad4d5 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -373,15 +373,18 @@ def get_sql_initial_data_for_model(model): def get_sql_initial_data(app): "Returns a list of the initial INSERT SQL statements for the given app." from django.db.models import get_models - output = [] + connection_output = {} app_models = get_models(app) - app_dir = os.path.normpath(os.path.join(os.path.dirname(app.__file__), 'sql')) - for klass in app_models: - output.extend(get_sql_initial_data_for_model(klass)) + opts = klass._meta + connection_name = opts.db_connection or _default + output = connection_output.setdefault(connection_name, []) + info = opts.connection_info + builder = info.get_creation_module().builder + output.extend(builder.get_initialdata(klass)) - return output + return _collate(connection_output) get_sql_initial_data.help_doc = "Prints the initial INSERT SQL statements for the given app name(s)." get_sql_initial_data.args = APP_ARGS @@ -414,10 +417,10 @@ get_sql_sequence_reset.args = APP_ARGS def get_sql_indexes(app): "Returns a list of the CREATE INDEX SQL statements for the given app." - from django.db import models + from django.db.models import get_models connection_output = {} - for klass in models.get_models(app): + for klass in get_models(app): opts = klass._meta connection_name = opts.db_connection or _default output = connection_output.setdefault(connection_name, []) diff --git a/django/db/backends/ansi/sql.py b/django/db/backends/ansi/sql.py index 28f6f05697..6268515831 100644 --- a/django/db/backends/ansi/sql.py +++ b/django/db/backends/ansi/sql.py @@ -241,9 +241,7 @@ class SchemaBuilder(object): output.reverse() return output - def get_initialdata(self, model, style=None): - if style is None: - style = default_style + def get_initialdata(self, model): opts = model._meta info = opts.connection_info settings = info.connection.settings