Ticket #17957: 17957.patch

File 17957.patch, 3.4 KB (added by Erin Kelly, 13 years ago)
  • django/db/backends/creation.py

     
    5050            # Make the definition (e.g. 'foo VARCHAR(30)') for this field.
    5151            field_output = [style.SQL_FIELD(qn(f.column)),
    5252                style.SQL_COLTYPE(col_type)]
    53             if not f.null:
     53            # Oracle treats the empty string ('') as null, so coerce the null
     54            # option whenever '' is a possible value.
     55            null = f.null
     56            if (f.empty_strings_allowed and not f.primary_key and
     57                    self.connection.features.interprets_empty_strings_as_nulls):
     58                null = True
     59            if not null:
    5460                field_output.append(style.SQL_KEYWORD('NOT NULL'))
    5561            if f.primary_key:
    5662                field_output.append(style.SQL_KEYWORD('PRIMARY KEY'))
  • django/db/models/fields/__init__.py

     
    8585        self.primary_key = primary_key
    8686        self.max_length, self._unique = max_length, unique
    8787        self.blank, self.null = blank, null
    88         # Oracle treats the empty string ('') as null, so coerce the null
    89         # option whenever '' is a possible value.
    90         if (self.empty_strings_allowed and
    91             connection.features.interprets_empty_strings_as_nulls):
    92             self.null = True
    9388        self.rel = rel
    9489        self.default = default
    9590        self.editable = editable
  • docs/ref/databases.txt

     
    679679
    680680Django generally prefers to use the empty string ('') rather than
    681681NULL, but Oracle treats both identically. To get around this, the
    682 Oracle backend coerces the ``null=True`` option on fields that have
    683 the empty string as a possible value. When fetching from the database,
    684 it is assumed that a NULL value in one of these fields really means
    685 the empty string, and the data is silently converted to reflect this
    686 assumption.
     682Oracle backend ignores an explicit ``null`` option on fields that
     683have the empty string as a possible value and generates DDL as if
     684``null=True``. When fetching from the database, it is assumed that
     685a ``NULL`` value in one of these fields really means the empty
     686string, and the data is silently converted to reflect this assumption.
    687687
    688688``TextField`` limitations
    689689-------------------------
  • docs/ref/models/fields.txt

     
    5555
    5656.. note::
    5757
    58     When using the Oracle database backend, the ``null=True`` option will be
    59     coerced for string-based fields that have the empty string as a possible
    60     value, and the value ``NULL`` will be stored to denote the empty string.
     58    When using the Oracle database backend, the value ``NULL`` will be stored to
     59    denote the empty string regardless of this attribute.
    6160
    6261If you want to accept :attr:`~Field.null` values with :class:`BooleanField`,
    6362use :class:`NullBooleanField` instead.
Back to Top