@staticmethod
def query(dbversion=None):
    """Returns query to fetch Rule instances from the catalogs"""
    return """
            SELECT nspname AS schema, relname AS table, rulename AS name,
                   split_part('select,update,insert,delete', ',',
                       ev_type::int - 48) AS event, is_instead AS instead,
                   pg_get_ruledef(r.oid) AS definition,
                   obj_description(r.oid, 'pg_rewrite') AS description, r.oid
            FROM pg_rewrite r JOIN pg_class c ON (ev_class = c.oid)
                 JOIN pg_namespace n ON (relnamespace = n.oid)
            WHERE relkind = 'r'
              AND (nspname != 'pg_catalog' AND nspname != 'information_schema')
            ORDER BY nspname, relname, rulename"""
