Changeset 709 for branches/4.x


Ignore:
Timestamp:
Jan 10, 2016, 5:12:03 PM (4 years ago)
Author:
cito
Message:

get_tables() should not list the information schema tables

Since get_tables() does not return the other system tables starting with pg_,
so it should not return the information schema tables either.

Also removed an ancient check for tables starting with Inv
that is not relevant any more since PostgreSQL 7.1 or so.

Location:
branches/4.x
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/docs/contents/changelog.rst

    r708 r709  
    1111- Add option to return boolean values as bool objects.
    1212- Add option to return money values as string.
     13- get_tables() does not list information schema tables any more.
    1314- Fix notification handler (Thanks Patrick TJ McPhee).
    1415- Fix a small issue with large objects.
  • branches/4.x/module/pg.py

    r706 r709  
    623623            ["'%s'" % x for x in kinds]) or ''
    624624        return [_join_parts(x) for x in self.db.query(
    625             "SELECT pg_namespace.nspname, pg_class.relname "
    626             "FROM pg_class "
    627             "JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace "
    628             "WHERE %s pg_class.relname !~ '^Inv' AND "
    629                 "pg_class.relname !~ '^pg_' "
    630             "ORDER BY 1, 2" % where).getresult()]
     625            "SELECT pg_namespace.nspname, pg_class.relname"
     626            " FROM pg_class "
     627            " JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace "
     628            " WHERE %s pg_namespace.nspname != 'information_schema'"
     629                " AND pg_namespace.nspname !~ '^pg_' "
     630            " ORDER BY 1, 2" % where).getresult()]
    631631
    632632    def get_tables(self):
  • branches/4.x/module/tests/test_classic_dbwrapper.py

    r698 r709  
    558558        get_tables = self.db.get_tables
    559559        result1 = get_tables()
     560        self.assertIsInstance(result1, list)
     561        for t in result1:
     562            t = t.split('.', 1)
     563            self.assertGreaterEqual(len(t), 2)
     564            if len(t) > 2:
     565                self.assertTrue(t[1].startswith('"'))
     566            t = t[0]
     567            self.assertNotEqual(t, 'information_schema')
     568            self.assertFalse(t.startswith('pg_'))
    560569        tables = ('"A very Special Name"',
    561570            '"A_MiXeD_quoted_NaMe"', 'a1', 'a2',
Note: See TracChangeset for help on using the changeset viewer.