Changeset 709 for trunk/module/pg.py


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/pg.py

    r706 r709  
    105105def _join_parts(s):
    106106    """Join all parts of a dot separated string."""
    107     return '.'.join([_is_quoted(p) and '"%s"' % p or p for p in s])
     107    return '.'.join(['"%s"' % p if _is_quoted(p) else p for p in s])
    108108
    109109
     
    622622
    623623        """
    624         where = kinds and "pg_class.relkind IN (%s) AND" % ','.join(
    625             ["'%s'" % x for x in kinds]) or ''
     624        where = "pg_class.relkind IN (%s) AND" % ','.join(
     625            ["'%s'" % x for x in kinds]) if kinds else ''
    626626        return [_join_parts(x) for x in self.db.query(
    627             "SELECT pg_namespace.nspname, pg_class.relname "
    628             "FROM pg_class "
    629             "JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace "
    630             "WHERE %s pg_class.relname !~ '^Inv' AND "
    631                 "pg_class.relname !~ '^pg_' "
    632             "ORDER BY 1, 2" % where).getresult()]
     627            "SELECT pg_namespace.nspname, pg_class.relname"
     628            " FROM pg_class "
     629            " JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace "
     630            " WHERE %s pg_namespace.nspname != 'information_schema'"
     631                " AND pg_namespace.nspname !~ '^pg_' "
     632            " ORDER BY 1, 2" % where).getresult()]
    633633
    634634    def get_tables(self):
Note: See TracChangeset for help on using the changeset viewer.