Ticket #8316: db-mysqltypeissue.2.diff
File db-mysqltypeissue.2.diff, 5.5 KB (added by , 16 years ago) |
---|
-
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(Field): 812 empty_strings_allowed = False 813 def get_db_prep_value(self, value): 814 if value is None: 815 return None 816 return int(value) 817 818 def get_manipulator_field_objs(self): 819 return [oldforms.IntegerField] 820 821 def get_internal_type(self): 822 return "KeyField" 823 824 def formfield(self, **kwargs): 825 defaults = {'form_class': forms.IntegerField} 826 defaults.update(kwargs) 827 return super(KeyField, self).formfield(**defaults) 828 811 829 class NullBooleanField(Field): 812 830 empty_strings_allowed = False 813 831 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 … … 710 710 def db_type(self): 711 711 # The database column type of a ForeignKey is the column type 712 712 # of the field to which it points. An exception is if the ForeignKey 713 # points to an AutoField /PositiveIntegerField/PositiveSmallIntegerField,714 # in which case the column type is simply that of an IntegerField.713 # points to an AutoField, in which case the column type is simply that 714 # of a KeyField. 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 return KeyField().db_type() 718 718 return rel_field.db_type() 719 719 720 720 class OneToOneField(ForeignKey):