Ticket #9525: django_foreign_key.patch
File django_foreign_key.patch, 1.9 KB (added by , 16 years ago) |
---|
-
db/backends/creation.py
56 56 # We must specify the index tablespace inline, because we 57 57 # won't be generating a CREATE INDEX statement for this field. 58 58 field_output.append(self.connection.ops.tablespace_sql(tablespace, inline=True)) 59 if f.rel :59 if f.rel and f.create_constraint: 60 60 ref_output, pending = self.sql_for_inline_foreign_key_references(f, known_models, style) 61 61 if pending: 62 62 pr = pending_references.setdefault(f.rel.to, []).append((model, f)) … … 93 93 def sql_for_inline_foreign_key_references(self, field, known_models, style): 94 94 "Return the SQL snippet defining the foreign key reference for a field" 95 95 qn = self.connection.ops.quote_name 96 if field.rel.to in known_models :96 if field.rel.to in known_models and field.create_constraint: 97 97 output = [style.SQL_KEYWORD('REFERENCES') + ' ' + \ 98 98 style.SQL_TABLE(qn(field.rel.to._meta.db_table)) + ' (' + \ 99 99 style.SQL_FIELD(qn(field.rel.to._meta.get_field(field.rel.field_name).column)) + ')' + -
db/models/fields/related.py
641 641 limit_choices_to=kwargs.pop('limit_choices_to', None), 642 642 lookup_overrides=kwargs.pop('lookup_overrides', None), 643 643 parent_link=kwargs.pop('parent_link', False)) 644 self.create_constraint = kwargs.pop('create_constraint',True) 644 645 Field.__init__(self, **kwargs) 645 646 646 647 self.db_index = True