Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[soc2010/query-refactor] Remove some nastiness from db_type()

  • Loading branch information...
commit f70c9985c20681a00e63457c2c11b30ab9235d33 1 parent 7dcb95a
@alex alex authored
View
1  django/contrib/mongodb/base.py
@@ -9,7 +9,6 @@
class DatabaseFeatures(object):
interprets_empty_strings_as_nulls = False
- typed_columns = False
sql_nulls = False
View
3  django/contrib/mongodb/creation.py
@@ -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
9 django/db/backends/creation.py
@@ -3,6 +3,8 @@
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.
@@ -26,6 +28,13 @@ def _digest(self, *args):
shorten identifying names.
"""
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()):
"""
View
9 django/db/models/fields/__init__.py
@@ -13,7 +13,6 @@
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 @@ def db_type(self, connection):
# 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
Please sign in to comment.
Something went wrong with that request. Please try again.