Ticket #17957: 17957.patch
File 17957.patch, 3.4 KB (added by , 13 years ago) |
---|
-
django/db/backends/creation.py
50 50 # Make the definition (e.g. 'foo VARCHAR(30)') for this field. 51 51 field_output = [style.SQL_FIELD(qn(f.column)), 52 52 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: 54 60 field_output.append(style.SQL_KEYWORD('NOT NULL')) 55 61 if f.primary_key: 56 62 field_output.append(style.SQL_KEYWORD('PRIMARY KEY')) -
django/db/models/fields/__init__.py
85 85 self.primary_key = primary_key 86 86 self.max_length, self._unique = max_length, unique 87 87 self.blank, self.null = blank, null 88 # Oracle treats the empty string ('') as null, so coerce the null89 # option whenever '' is a possible value.90 if (self.empty_strings_allowed and91 connection.features.interprets_empty_strings_as_nulls):92 self.null = True93 88 self.rel = rel 94 89 self.default = default 95 90 self.editable = editable -
docs/ref/databases.txt
679 679 680 680 Django generally prefers to use the empty string ('') rather than 681 681 NULL, but Oracle treats both identically. To get around this, the 682 Oracle backend coerces the ``null=True`` option on fields that have683 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.682 Oracle backend ignores an explicit ``null`` option on fields that 683 have the empty string as a possible value and generates DDL as if 684 ``null=True``. When fetching from the database, it is assumed that 685 a ``NULL`` value in one of these fields really means the empty 686 string, and the data is silently converted to reflect this assumption. 687 687 688 688 ``TextField`` limitations 689 689 ------------------------- -
docs/ref/models/fields.txt
55 55 56 56 .. note:: 57 57 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. 61 60 62 61 If you want to accept :attr:`~Field.null` values with :class:`BooleanField`, 63 62 use :class:`NullBooleanField` instead.