Changeset 788 for trunk/tests


Ignore:
Timestamp:
Jan 26, 2016, 4:13:55 PM (3 years ago)
Author:
cito
Message:

Add method columns() to type cache

The method returns the columns of composite types.
This makes the type cache even more useful.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/test_dbapi20.py

    r787 r788  
    294294        con = self._connect()
    295295        cur = con.cursor()
    296         type_info = cur.type_cache['numeric']
     296        type_cache = cur.type_cache
     297        type_info = type_cache['numeric']
    297298        self.assertEqual(type_info.oid, 1700)
    298299        self.assertEqual(type_info.name, 'numeric')
     
    301302        self.assertEqual(type_info.delim, ',')
    302303        self.assertIs(cur.type_cache[1700], type_info)
     304        type_info = type_cache['pg_type']
     305        self.assertEqual(type_info.type, 'c')  # composite
     306        self.assertEqual(type_info.category, 'C')  # composite
     307        cols = type_cache.columns('pg_type')
     308        self.assertEqual(cols[0].name, 'typname')
     309        typname = type_cache[cols[0].type]
     310        self.assertEqual(typname.name, 'name')
     311        self.assertEqual(typname.type, 'b')  # base
     312        self.assertEqual(typname.category, 'S')  # string
     313        self.assertEqual(cols[3].name, 'typlen')
     314        typlen = type_cache[cols[3].type]
     315        self.assertEqual(typlen.name, 'int2')
     316        self.assertEqual(typlen.type, 'b')  # base
     317        self.assertEqual(typlen.category, 'N')  # numeric
    303318
    304319    def test_cursor_iteration(self):
Note: See TracChangeset for help on using the changeset viewer.