diff options
| author | Anv3sh <anveshgreat11@gmail.com> | 2021-09-21 22:49:58 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-10-26 09:50:23 +0200 |
| commit | 69af4d09bae7782f733e01b19cf69fa6f36d7165 (patch) | |
| tree | 871d2664f1aa42ae91e19635417d522435764a81 /tests/backends/sqlite | |
| parent | d446f8ba0820c8a4a923614611ae53582d38bc8e (diff) | |
Fixed #32672 -- Fixed introspection of primary key constraints on SQLite.
Thanks Simon Charette for the implementation idea.
Diffstat (limited to 'tests/backends/sqlite')
| -rw-r--r-- | tests/backends/sqlite/test_introspection.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/backends/sqlite/test_introspection.py b/tests/backends/sqlite/test_introspection.py index e378e0ee56..9331b5bb1a 100644 --- a/tests/backends/sqlite/test_introspection.py +++ b/tests/backends/sqlite/test_introspection.py @@ -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): |
