Skip to content

Commit f70c998

Browse files
committed
[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
1 parent 7dcb95a commit f70c998

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

django/contrib/mongodb/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
class DatabaseFeatures(object):
1111
interprets_empty_strings_as_nulls = False
12-
typed_columns = False
1312
sql_nulls = False
1413

1514

django/contrib/mongodb/creation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ class DatabaseCreation(object):
55
def __init__(self, connection):
66
self.connection = connection
77

8+
def db_type(self, field):
9+
return None
10+
811
def create_test_db(self, verbosity, autoclobber):
912
if self.connection.settings_dict['TEST_NAME']:
1013
test_database_name = self.connection.settings_dict['TEST_NAME']

django/db/backends/creation.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from django.conf import settings
55
from django.core.management import call_command
6+
from django.utils.datastructures import DictWrapper
7+
68

79
# The prefix to put on the default database name when creating
810
# the test database.
@@ -26,6 +28,13 @@ def _digest(self, *args):
2628
shorten identifying names.
2729
"""
2830
return '%x' % (abs(hash(args)) % 4294967296L) # 2**32
31+
32+
def db_type(self, field):
33+
data = DictWrapper(field.__dict__, self.connection.ops.quote_name, "qn_")
34+
try:
35+
return self.connection.creation.data_types[field.get_internal_type()] % data
36+
except KeyError:
37+
return None
2938

3039
def sql_create_model(self, model, style, known_models=set()):
3140
"""

django/db/models/fields/__init__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from django.conf import settings
1414
from django import forms
1515
from django.core import exceptions, validators
16-
from django.utils.datastructures import DictWrapper
1716
from django.utils.functional import curry
1817
from django.utils.text import capfirst
1918
from django.utils.translation import ugettext_lazy as _
@@ -215,13 +214,7 @@ def db_type(self, connection):
215214
# mapped to one of the built-in Django field types. In this case, you
216215
# can implement db_type() instead of get_internal_type() to specify
217216
# exactly which wacky database column type you want to use.
218-
if not getattr(connection.features, "typed_columns", True):
219-
return None
220-
data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_")
221-
try:
222-
return connection.creation.data_types[self.get_internal_type()] % data
223-
except KeyError:
224-
return None
217+
return connection.creation.db_type(self)
225218

226219
def unique(self):
227220
return self._unique or self.primary_key

0 commit comments

Comments
 (0)