mirror of
https://github.com/django/django.git
synced 2025-08-16 08:40:28 +00:00
Fixed #32672 -- Fixed introspection of primary key constraints on SQLite.
Thanks Simon Charette for the implementation idea.
This commit is contained in:
parent
d446f8ba08
commit
69af4d09ba
2 changed files with 23 additions and 17 deletions
|
@ -28,6 +28,25 @@ class IntrospectionTests(TestCase):
|
|||
finally:
|
||||
cursor.execute('DROP TABLE test_primary')
|
||||
|
||||
def test_get_primary_key_column_pk_constraint(self):
|
||||
sql = """
|
||||
CREATE TABLE test_primary(
|
||||
id INTEGER NOT NULL,
|
||||
created DATE,
|
||||
PRIMARY KEY(id)
|
||||
)
|
||||
"""
|
||||
with connection.cursor() as cursor:
|
||||
try:
|
||||
cursor.execute(sql)
|
||||
field = connection.introspection.get_primary_key_column(
|
||||
cursor,
|
||||
'test_primary',
|
||||
)
|
||||
self.assertEqual(field, 'id')
|
||||
finally:
|
||||
cursor.execute('DROP TABLE test_primary')
|
||||
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests')
|
||||
class ParsingTests(TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue