1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

Fix Oracle's default handling and schema-prepared-statement issue

This commit is contained in:
Andrew Godwin
2013-08-23 12:07:55 +01:00
parent ac45f9c9c5
commit 9cc6cfc405
4 changed files with 62 additions and 9 deletions

View File

@@ -1,4 +1,6 @@
import copy
import datetime
from django.utils import six
from django.db.backends.schema import BaseDatabaseSchemaEditor
from django.db.utils import DatabaseError
@@ -89,3 +91,13 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
"""
suffix = hex(hash(for_name)).upper()[1:]
return self.normalize_name(for_name + "_" + suffix)
def prepare_default(self, value):
if isinstance(value, (datetime.date, datetime.time, datetime.datetime)):
return "'%s'" % value
elif isinstance(value, six.string_types):
return repr(value)
elif isinstance(value, bool):
return "1" if value else "0"
else:
return str(value)