mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #27090 -- Added real database sequence introspection.
Thanks Mariusz Felisiak for the Oracle part and Tim Graham for the review.
This commit is contained in:
23
tests/backends/postgresql/test_introspection.py
Normal file
23
tests/backends/postgresql/test_introspection.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import unittest
|
||||
|
||||
from django.db import connection
|
||||
from django.test import TestCase
|
||||
|
||||
from ..models import Person
|
||||
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'postgresql', "Test only for PostgreSQL")
|
||||
class DatabaseSequenceTests(TestCase):
|
||||
def test_get_sequences(self):
|
||||
cursor = connection.cursor()
|
||||
seqs = connection.introspection.get_sequences(cursor, Person._meta.db_table)
|
||||
self.assertEqual(
|
||||
seqs,
|
||||
[{'table': Person._meta.db_table, 'column': 'id', 'name': 'backends_person_id_seq'}]
|
||||
)
|
||||
cursor.execute('ALTER SEQUENCE backends_person_id_seq RENAME TO pers_seq')
|
||||
seqs = connection.introspection.get_sequences(cursor, Person._meta.db_table)
|
||||
self.assertEqual(
|
||||
seqs,
|
||||
[{'table': Person._meta.db_table, 'column': 'id', 'name': 'pers_seq'}]
|
||||
)
|
||||
Reference in New Issue
Block a user