Ticket #399: bigint_patch_03jan07.diff

File bigint_patch_03jan07.diff, 4.4 KB (added by Gaël Chardon <gael.dev@…>, 8 years ago)
  • oldforms/__init__.py

     
    744744        if not 0 <= int(field_data) <= 32767:
    745745            raise validators.CriticalValidationError, gettext("Enter a whole number between 0 and 32,767.")
    746746
     747class BigIntegerField(IntegerField):
     748    def __init__(self, field_name, length=20, maxlength=None, is_required=False, validator_list=None, member_name=None):
     749        if validator_list is None: validator_list = []
     750        validator_list = [self.isInteger] + validator_list
     751        if member_name is not None:
     752            self.member_name = member_name
     753        IntegerField.__init__(self, field_name, length, maxlength, is_required, validator_list)
     754
     755class PositiveBigIntegerField(PositiveIntegerField):
     756    def __init__(self, field_name, length=20, maxlength=None, is_required=False, validator_list=None):
     757        if validator_list is None: validator_list = []
     758        validator_list = [self.isPositive] + validator_list
     759        IntegerField.__init__(self, field_name, length, maxlength, is_required, validator_list)
     760
    747761class FloatField(TextField):
    748762    def __init__(self, field_name, max_digits, decimal_places, is_required=False, validator_list=None):
    749763        if validator_list is None: validator_list = []
  • db/models/fields/__init__.py

     
    703703    def formfield(self, initial=None):
    704704        return forms.IntegerField(required=not self.blank, label=capfirst(self.verbose_name), initial=initial)
    705705
     706class BigIntegerField(IntegerField):
     707    def get_manipulator_field_objs(self):
     708        return [oldforms.BigIntegerField]
     709
     710class PositiveBigIntegerField(IntegerField):
     711    def get_manipulator_field_objs(self):
     712        return [oldforms.PositiveBigIntegerField]   
     713
    706714class IPAddressField(Field):
    707715    def __init__(self, *args, **kwargs):
    708716        kwargs['maxlength'] = 15
  • db/backends/mysql/introspection.py

     
    8383    FIELD_TYPE.FLOAT: 'FloatField',
    8484    FIELD_TYPE.INT24: 'IntegerField',
    8585    FIELD_TYPE.LONG: 'IntegerField',
    86     FIELD_TYPE.LONGLONG: 'IntegerField',
     86    FIELD_TYPE.LONGLONG: 'BigIntegerField',
    8787    FIELD_TYPE.SHORT: 'IntegerField',
    8888    FIELD_TYPE.STRING: 'TextField',
    8989    FIELD_TYPE.TIMESTAMP: 'DateTimeField',
  • db/backends/mysql/creation.py

     
    1414    'FloatField':        'numeric(%(max_digits)s, %(decimal_places)s)',
    1515    'ImageField':        'varchar(100)',
    1616    'IntegerField':      'integer',
     17    'BigIntegerField':   'bigint',
    1718    'IPAddressField':    'char(15)',
    1819    'ManyToManyField':   None,
    1920    'NullBooleanField':  'bool',
    2021    'OneToOneField':     'integer',
    2122    'PhoneNumberField':  'varchar(20)',
    2223    'PositiveIntegerField': 'integer UNSIGNED',
     24    'PositiveBigIntegerField': 'bigint UNSIGNED',   
    2325    'PositiveSmallIntegerField': 'smallint UNSIGNED',
    2426    'SlugField':         'varchar(%(maxlength)s)',
    2527    'SmallIntegerField': 'smallint',
  • contrib/admin/views/doc.py

     
    301301    'ForeignKey'                : _('Integer'),
    302302    'ImageField'                : _('File path'),
    303303    'IntegerField'              : _('Integer'),
     304    'BigIntegerField'           : _('Integer'),
    304305    'IPAddressField'            : _('IP address'),
    305306    'ManyToManyField'           : '',
    306307    'NullBooleanField'          : _('Boolean (Either True, False or None)'),
    307308    'OneToOneField'             : _('Relation to parent model'),
    308309    'PhoneNumberField'          : _('Phone number'),
    309310    'PositiveIntegerField'      : _('Integer'),
     311    'PositiveBigIntegerField'   : _('Integer'),
    310312    'PositiveSmallIntegerField' : _('Integer'),
    311313    'SlugField'                 : _('String (up to %(maxlength)s)'),
    312314    'SmallIntegerField'         : _('Integer'),
Back to Top