Changeset 5254
- Timestamp:
- 05/15/07 17:45:52 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/boulder-oracle-sprint/django/db/backends/oracle/base.py
r5149 r5254 467 467 if isinstance(value, Database.LOB): 468 468 value = value.read() 469 # Since Oracle won't distinguish between NULL and an empty 470 # string (''), we store empty strings as a space. Here is 471 # where we undo that treachery. 472 if value == ' ': 469 # Oracle stores empty strings as null. We need to undo this in 470 # order to adhere to the Django convention of using the empty 471 # string instead of null, but only if the field accepts the 472 # empty string. 473 if value is None and field.empty_strings_allowed: 473 474 value = '' 474 475 # Convert 1 or 0 to True or False django/branches/boulder-oracle-sprint/django/db/models/fields/__init__.py
r5135 r5254 77 77 self.maxlength, self.unique = maxlength, unique 78 78 self.blank, self.null = blank, null 79 # Oracle treats the empty string ('') as null, so coerce the null 80 # option whenever '' is a possible value. 81 if self.empty_strings_allowed and settings.DATABASE_ENGINE == 'oracle': 82 self.null = True 79 83 self.core, self.rel, self.default = core, rel, default 80 84 self.editable = editable … … 163 167 def get_db_prep_save(self, value): 164 168 "Returns field's value prepared for saving into a database." 165 # Oracle treats empty strings ('') the same as NULLs.166 # To get around this wart, we need to change it to something else...167 if settings.DATABASE_ENGINE == 'oracle' and value == '':168 value = ' '169 169 return value 170 170
