Ticket #9525: django_foreign_key.patch

File django_foreign_key.patch, 1.9 KB (added by mohlendo, 16 years ago)

simple patch for this ticket

  • db/backends/creation.py

     
    5656                # We must specify the index tablespace inline, because we
    5757                # won't be generating a CREATE INDEX statement for this field.
    5858                field_output.append(self.connection.ops.tablespace_sql(tablespace, inline=True))
    59             if f.rel:
     59            if f.rel and f.create_constraint:
    6060                ref_output, pending = self.sql_for_inline_foreign_key_references(f, known_models, style)
    6161                if pending:
    6262                    pr = pending_references.setdefault(f.rel.to, []).append((model, f))
     
    9393    def sql_for_inline_foreign_key_references(self, field, known_models, style):
    9494        "Return the SQL snippet defining the foreign key reference for a field"
    9595        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:
    9797            output = [style.SQL_KEYWORD('REFERENCES') + ' ' + \
    9898                style.SQL_TABLE(qn(field.rel.to._meta.db_table)) + ' (' + \
    9999                style.SQL_FIELD(qn(field.rel.to._meta.get_field(field.rel.field_name).column)) + ')' +
  • db/models/fields/related.py

     
    641641            limit_choices_to=kwargs.pop('limit_choices_to', None),
    642642            lookup_overrides=kwargs.pop('lookup_overrides', None),
    643643            parent_link=kwargs.pop('parent_link', False))
     644        self.create_constraint = kwargs.pop('create_constraint',True)
    644645        Field.__init__(self, **kwargs)
    645646
    646647        self.db_index = True
Back to Top