diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-10-11 03:36:36 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-10-11 03:37:09 +0100 |
commit | f99a8de6d04e109766ec4fc2ad276ff763e86cb1 (patch) | |
tree | b78e38a6038b4fc18749337c08ceb1dca3a2d8da /tests/test_cursor.py | |
parent | b3b225a9da450ed11ffbe8a61ba28ca6b343af32 (diff) | |
download | psycopg2-description-extra-attrs.tar.gz |
Added table_oid, table_column on cursor.description itemsdescription-extra-attrs
Close #661
Diffstat (limited to 'tests/test_cursor.py')
-rwxr-xr-x | tests/test_cursor.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 37110db..d048f3e 100755 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -377,7 +377,7 @@ class CursorTests(ConnectingTestCase): for i, rec in enumerate(curs): self.assertEqual(i + 1, curs.rownumber) - def test_namedtuple_description(self): + def test_description_attribs(self): curs = self.conn.cursor() curs.execute("""select 3.14::decimal(10,2) as pi, @@ -412,6 +412,27 @@ class CursorTests(ConnectingTestCase): self.assertEqual(c.precision, None) self.assertEqual(c.scale, None) + def test_description_extra_attribs(self): + curs = self.conn.cursor() + curs.execute(""" + create table testcol ( + pi decimal(10,2), + hi text) + """) + curs.execute("select oid from pg_class where relname = %s", ('testcol',)) + oid = curs.fetchone()[0] + + curs.execute("insert into testcol values (3.14, 'hello')") + curs.execute("select hi, pi, 42 from testcol") + self.assertEqual(curs.description[0].table_oid, oid) + self.assertEqual(curs.description[0].table_column, 2) + + self.assertEqual(curs.description[1].table_oid, oid) + self.assertEqual(curs.description[1].table_column, 1) + + self.assertEqual(curs.description[2].table_oid, None) + self.assertEqual(curs.description[2].table_column, None) + def test_pickle_description(self): curs = self.conn.cursor() curs.execute('SELECT 1 AS foo') |