Ticket #8316: db-mysqltypeissue.4.diff
File db-mysqltypeissue.4.diff, 5.9 KB (added by , 16 years ago) |
---|
-
django/db/backends/__init__.py
71 71 interprets_empty_strings_as_nulls = False 72 72 can_use_chunked_reads = True 73 73 uses_savepoints = False 74 keys_need_similar_types = False 74 75 75 76 class BaseDatabaseOperations(object): 76 77 """ -
django/db/backends/mysql/base.py
80 80 class DatabaseFeatures(BaseDatabaseFeatures): 81 81 empty_fetchmany_value = () 82 82 update_can_self_select = False 83 keys_need_similar_types = True 83 84 84 85 class DatabaseOperations(BaseDatabaseOperations): 85 86 def date_extract_sql(self, lookup_type, field_name): -
django/db/backends/mysql/creation.py
19 19 'FloatField': 'double precision', 20 20 'IntegerField': 'integer', 21 21 'IPAddressField': 'char(15)', 22 'KeyField': 'integer', 22 23 'NullBooleanField': 'bool', 23 'OneToOneField': 'integer',24 24 'PhoneNumberField': 'varchar(20)', 25 25 'PositiveIntegerField': 'integer UNSIGNED', 26 26 'PositiveSmallIntegerField': 'smallint UNSIGNED', -
django/db/backends/oracle/creation.py
28 28 'FloatField': 'DOUBLE PRECISION', 29 29 'IntegerField': 'NUMBER(11)', 30 30 'IPAddressField': 'VARCHAR2(15)', 31 'KeyField': 'NUMBER(11)', 31 32 'NullBooleanField': 'NUMBER(1) CHECK ((%(qn_column)s IN (0,1)) OR (%(qn_column)s IS NULL))', 32 'OneToOneField': 'NUMBER(11)',33 33 'PhoneNumberField': 'VARCHAR2(20)', 34 34 'PositiveIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 0)', 35 35 'PositiveSmallIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 0)', -
django/db/backends/postgresql/creation.py
19 19 'FloatField': 'double precision', 20 20 'IntegerField': 'integer', 21 21 'IPAddressField': 'inet', 22 'KeyField': 'integer', 22 23 'NullBooleanField': 'boolean', 23 'OneToOneField': 'integer',24 24 'PhoneNumberField': 'varchar(20)', 25 25 'PositiveIntegerField': 'integer CHECK ("%(column)s" >= 0)', 26 26 'PositiveSmallIntegerField': 'smallint CHECK ("%(column)s" >= 0)', -
django/db/backends/sqlite3/creation.py
20 20 'FloatField': 'real', 21 21 'IntegerField': 'integer', 22 22 'IPAddressField': 'char(15)', 23 'KeyField': 'integer', 23 24 'NullBooleanField': 'bool', 24 'OneToOneField': 'integer',25 25 'PhoneNumberField': 'varchar(20)', 26 26 'PositiveIntegerField': 'integer unsigned', 27 27 'PositiveSmallIntegerField': 'smallint unsigned', -
django/db/models/fields/__init__.py
808 808 defaults.update(kwargs) 809 809 return super(IPAddressField, self).formfield(**defaults) 810 810 811 class KeyField(IntegerField): 812 pass 813 811 814 class NullBooleanField(Field): 812 815 empty_strings_allowed = False 813 816 def __init__(self, *args, **kwargs): -
django/db/models/fields/related.py
1 1 from django.db import connection, transaction 2 2 from django.db.models import signals, get_model 3 from django.db.models.fields import AutoField, Field, IntegerField, PositiveIntegerField, PositiveSmallIntegerField, FieldDoesNotExist3 from django.db.models.fields import AutoField, Field, KeyField, PositiveIntegerField, PositiveSmallIntegerField, FieldDoesNotExist 4 4 from django.db.models.related import RelatedObject 5 5 from django.db.models.query import QuerySet 6 6 from django.db.models.query_utils import QueryWrapper … … 713 713 # points to an AutoField/PositiveIntegerField/PositiveSmallIntegerField, 714 714 # in which case the column type is simply that of an IntegerField. 715 715 rel_field = self.rel.get_related_field() 716 if isinstance(rel_field, (AutoField, PositiveIntegerField, PositiveSmallIntegerField)): 717 return IntegerField().db_type() 716 if isinstance(rel_field, AutoField) \ 717 or (not connection.features.keys_need_similar_types and 718 isinstance(rel_field, (AutoField, 719 PositiveIntegerField, 720 PositiveSmallIntegerField))): 721 return KeyField().db_type() 718 722 return rel_field.db_type() 719 723 720 724 class OneToOneField(ForeignKey):