mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
[soc2010/query-refactor] Remove some nastiness from db_type()
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13409 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
7dcb95ae9a
commit
f70c9985c2
@ -9,7 +9,6 @@ from django.utils.importlib import import_module
|
|||||||
|
|
||||||
class DatabaseFeatures(object):
|
class DatabaseFeatures(object):
|
||||||
interprets_empty_strings_as_nulls = False
|
interprets_empty_strings_as_nulls = False
|
||||||
typed_columns = False
|
|
||||||
sql_nulls = False
|
sql_nulls = False
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,9 @@ class DatabaseCreation(object):
|
|||||||
def __init__(self, connection):
|
def __init__(self, connection):
|
||||||
self.connection = connection
|
self.connection = connection
|
||||||
|
|
||||||
|
def db_type(self, field):
|
||||||
|
return None
|
||||||
|
|
||||||
def create_test_db(self, verbosity, autoclobber):
|
def create_test_db(self, verbosity, autoclobber):
|
||||||
if self.connection.settings_dict['TEST_NAME']:
|
if self.connection.settings_dict['TEST_NAME']:
|
||||||
test_database_name = self.connection.settings_dict['TEST_NAME']
|
test_database_name = self.connection.settings_dict['TEST_NAME']
|
||||||
|
@ -3,6 +3,8 @@ import time
|
|||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
|
from django.utils.datastructures import DictWrapper
|
||||||
|
|
||||||
|
|
||||||
# The prefix to put on the default database name when creating
|
# The prefix to put on the default database name when creating
|
||||||
# the test database.
|
# the test database.
|
||||||
@ -26,6 +28,13 @@ class BaseDatabaseCreation(object):
|
|||||||
shorten identifying names.
|
shorten identifying names.
|
||||||
"""
|
"""
|
||||||
return '%x' % (abs(hash(args)) % 4294967296L) # 2**32
|
return '%x' % (abs(hash(args)) % 4294967296L) # 2**32
|
||||||
|
|
||||||
|
def db_type(self, field):
|
||||||
|
data = DictWrapper(field.__dict__, self.connection.ops.quote_name, "qn_")
|
||||||
|
try:
|
||||||
|
return self.connection.creation.data_types[field.get_internal_type()] % data
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
def sql_create_model(self, model, style, known_models=set()):
|
def sql_create_model(self, model, style, known_models=set()):
|
||||||
"""
|
"""
|
||||||
|
@ -13,7 +13,6 @@ from django.db.models.query_utils import QueryWrapper
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core import exceptions, validators
|
from django.core import exceptions, validators
|
||||||
from django.utils.datastructures import DictWrapper
|
|
||||||
from django.utils.functional import curry
|
from django.utils.functional import curry
|
||||||
from django.utils.text import capfirst
|
from django.utils.text import capfirst
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -215,13 +214,7 @@ class Field(object):
|
|||||||
# mapped to one of the built-in Django field types. In this case, you
|
# mapped to one of the built-in Django field types. In this case, you
|
||||||
# can implement db_type() instead of get_internal_type() to specify
|
# can implement db_type() instead of get_internal_type() to specify
|
||||||
# exactly which wacky database column type you want to use.
|
# exactly which wacky database column type you want to use.
|
||||||
if not getattr(connection.features, "typed_columns", True):
|
return connection.creation.db_type(self)
|
||||||
return None
|
|
||||||
data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_")
|
|
||||||
try:
|
|
||||||
return connection.creation.data_types[self.get_internal_type()] % data
|
|
||||||
except KeyError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def unique(self):
|
def unique(self):
|
||||||
return self._unique or self.primary_key
|
return self._unique or self.primary_key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user