1
0
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:
Alex Gaynor 2010-07-01 01:57:12 +00:00
parent 7dcb95ae9a
commit f70c9985c2
4 changed files with 13 additions and 9 deletions

View File

@ -9,7 +9,6 @@ from django.utils.importlib import import_module
class DatabaseFeatures(object):
interprets_empty_strings_as_nulls = False
typed_columns = False
sql_nulls = False

View File

@ -5,6 +5,9 @@ class DatabaseCreation(object):
def __init__(self, connection):
self.connection = connection
def db_type(self, field):
return None
def create_test_db(self, verbosity, autoclobber):
if self.connection.settings_dict['TEST_NAME']:
test_database_name = self.connection.settings_dict['TEST_NAME']

View File

@ -3,6 +3,8 @@ import time
from django.conf import settings
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 test database.
@ -27,6 +29,13 @@ class BaseDatabaseCreation(object):
"""
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()):
"""
Returns the SQL required to create a single model, as a tuple of:

View File

@ -13,7 +13,6 @@ from django.db.models.query_utils import QueryWrapper
from django.conf import settings
from django import forms
from django.core import exceptions, validators
from django.utils.datastructures import DictWrapper
from django.utils.functional import curry
from django.utils.text import capfirst
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
# can implement db_type() instead of get_internal_type() to specify
# exactly which wacky database column type you want to use.
if not getattr(connection.features, "typed_columns", True):
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
return connection.creation.db_type(self)
def unique(self):
return self._unique or self.primary_key