Al...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed 23170fb

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

  • Participants
  • Parent commits 0faa408
  • Branches soc2010/query-refactor

Comments (0)

Files changed (4)

File django/contrib/mongodb/

 class DatabaseFeatures(object):
     interprets_empty_strings_as_nulls = False
-    typed_columns = False
     sql_nulls = False

File django/contrib/mongodb/

     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']

File django/db/backends/

 from django.conf import settings
 from import call_command
+from django.utils.datastructures import DictWrapper
 # The prefix to put on the default database name when creating
 # the test database.
         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()):

File django/db/models/fields/

 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 _
         # 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