Ticket #27979: 27979.diff

File 27979.diff, 1.5 KB (added by Tim Graham, 8 years ago)
  • django/db/backends/mysql/base.py

    diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
    index 08632a0..54fb2fe 100644
    a b class CursorWrapper:  
    5757    Implemented as a wrapper, rather than a subclass, so that it isn't stuck
    5858    to the particular underlying representation returned by Connection.cursor().
    5959    """
    60     codes_for_integrityerror = (1048,)
     60    codes_for_integrityerror = (
     61        1048,  # Column cannot be null
     62        1690,  # BIGINT UNSIGNED value is out of range
     63    )
    6164
    6265    def __init__(self, cursor):
    6366        self.cursor = cursor
  • tests/model_fields/test_integerfield.py

    diff --git a/tests/model_fields/test_integerfield.py b/tests/model_fields/test_integerfield.py
    index 99d7b17..8661c28 100644
    a b  
    11from django.core import validators
    22from django.core.exceptions import ValidationError
    3 from django.db import connection, models
     3from django.db import IntegrityError, connection, models
    44from django.test import SimpleTestCase, TestCase
    55
    66from .models import (
    class PositiveIntegerFieldTests(IntegerFieldTests):  
    151151    model = PositiveIntegerModel
    152152    documented_range = (0, 2147483647)
    153153
     154    def test_negative_values(self):
     155        p = PositiveIntegerModel.objects.create(value=0)
     156        p.value = models.F('value') - 1
     157        with self.assertRaises(IntegrityError):
     158           p.save()
     159
    154160
    155161class ValidationTests(SimpleTestCase):
    156162
Back to Top