Fixed #10164 -- Made AutoField increase monotonically on SQLite

Thanks malte for the report.
This commit is contained in:
Chris Wilson 2013-09-06 12:18:16 -04:00 committed by Tim Graham
parent 630eb0564a
commit eade315da1
7 changed files with 40 additions and 1 deletions

View file

@ -4,6 +4,7 @@ from __future__ import unicode_literals
import datetime
from decimal import Decimal
import re
import threading
import unittest
@ -108,6 +109,25 @@ class OracleChecks(unittest.TestCase):
self.assertEqual(c.fetchone()[0], 1)
class SQLiteTests(TestCase):
longMessage = True
@unittest.skipUnless(connection.vendor == 'sqlite',
"Test valid only for SQLite")
def test_autoincrement(self):
"""
Check that auto_increment fields are created with the AUTOINCREMENT
keyword in order to be monotonically increasing. Refs #10164.
"""
statements = connection.creation.sql_create_model(models.Square,
style=no_style())
match = re.search('"id" ([^,]+),', statements[0][0])
self.assertIsNotNone(match)
self.assertEqual('integer NOT NULL PRIMARY KEY AUTOINCREMENT',
match.group(1), "Wrong SQL used to create an auto-increment "
"column on SQLite")
class MySQLTests(TestCase):
@unittest.skipUnless(connection.vendor == 'mysql',
"Test valid only for MySQL")