mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #10164 -- Made AutoField increase monotonically on SQLite
Thanks malte for the report.
This commit is contained in:
parent
630eb0564a
commit
eade315da1
7 changed files with 40 additions and 1 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue