1
0
mirror of https://github.com/django/django.git synced 2025-07-04 01:39:20 +00:00

gis: Fixed _post_create_sql hook to not generate additional SQL for fields belonging to a parent model via model inheritance. Thanks, robotika.

git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7513 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Justin Bronn 2008-05-02 18:38:06 +00:00
parent 57c700d550
commit 579c9d4567

View File

@ -436,9 +436,12 @@ def custom_sql_for_model(model, style):
output = []
# Post-creation SQL should come before any initial SQL data is loaded.
for f in opts.fields:
if hasattr(f, '_post_create_sql'):
output.extend(f._post_create_sql(style, model._meta.db_table))
# However, this should not be done for fields that are part of a
# a parent model (via model inheritance).
nm = opts.init_name_map()
post_sql_fields = [f for f in opts.fields if nm[f.name][1] is None and hasattr(f, '_post_create_sql')]
for f in post_sql_fields:
output.extend(f._post_create_sql(style, model._meta.db_table))
# Some backends can't execute more than one SQL statement at a time,
# so split into separate statements.