mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
[multi-db] Fixed orphan pending error message. Changed get_create_table to only fill pending if backend supports constraints.
git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3762 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c01d2f4e6a
commit
ecb5b81e0d
@ -411,16 +411,15 @@ def _install(app, commit=True, initial_data=True):
|
|||||||
models_installed = manager.get_installed_models(tables)
|
models_installed = manager.get_installed_models(tables)
|
||||||
|
|
||||||
for model in pending.keys():
|
for model in pending.keys():
|
||||||
|
manager = model._default_manager
|
||||||
if model in models_installed:
|
if model in models_installed:
|
||||||
for rel_class, f in pending[model]:
|
for rel_class, f in pending[model]:
|
||||||
manager = model._default_manager
|
|
||||||
for statement in manager.get_pending(rel_class, f):
|
for statement in manager.get_pending(rel_class, f):
|
||||||
statement.execute()
|
statement.execute()
|
||||||
pending.pop(model)
|
pending.pop(model)
|
||||||
else:
|
else:
|
||||||
raise Exception("%s is not installed, but there are "
|
raise Exception("%s is not installed, but it has pending "
|
||||||
"pending statements that need it: %s"
|
"references" % model)
|
||||||
% (model, statements))
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
import traceback
|
import traceback
|
||||||
print traceback.format_exception(*sys.exc_info())
|
print traceback.format_exception(*sys.exc_info())
|
||||||
|
@ -103,7 +103,8 @@ class SchemaBuilder(object):
|
|||||||
else:
|
else:
|
||||||
# We haven't yet created the table to which this field
|
# We haven't yet created the table to which this field
|
||||||
# is related, so save it for later.
|
# is related, so save it for later.
|
||||||
pending.setdefault(f.rel.to, []).append((model, f))
|
if backend.supports_constraints:
|
||||||
|
pending.setdefault(f.rel.to, []).append((model, f))
|
||||||
table_output.append(' '.join(field_output))
|
table_output.append(' '.join(field_output))
|
||||||
if opts.order_with_respect_to:
|
if opts.order_with_respect_to:
|
||||||
table_output.append(style.SQL_FIELD(quote_name('_order')) + ' ' + \
|
table_output.append(style.SQL_FIELD(quote_name('_order')) + ' ' + \
|
||||||
@ -124,8 +125,7 @@ class SchemaBuilder(object):
|
|||||||
create = [BoundStatement('\n'.join(full_statement), db.connection)]
|
create = [BoundStatement('\n'.join(full_statement), db.connection)]
|
||||||
|
|
||||||
# Pull out any pending statements for me
|
# Pull out any pending statements for me
|
||||||
if (pending and
|
if pending:
|
||||||
backend.supports_constraints):
|
|
||||||
if model in pending:
|
if model in pending:
|
||||||
for rel_class, f in pending[model]:
|
for rel_class, f in pending[model]:
|
||||||
create.append(self.get_ref_sql(model, rel_class, f,
|
create.append(self.get_ref_sql(model, rel_class, f,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user