Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix queries to correctly exclude internal schemas.

 * dbobject/column.py (ColumnDict.query): Exclude pg_catalog and
   information_schema.
 * dbobject/constraint.py (ConstraintDict.query): Exclude pg_catalog
   and information_schema.
 * dbobject/index.py (IndexDict.query): Exclude pg_catalog and
   information_schema.
 * dbobject/schema.py (SchemaDict.query): Exclude information_schema,
   pg_catalog, pg_toast, pg_temp_1 and pg_toast_temp_1.
 * dbobject/table.py (ClassDict.query): Exclude pg_catalog and
   information_schema.
  • Loading branch information...
commit 5a6e4bc09bb19474559aa487a6c3fb572195a6f9 1 parent ac450bf
@jmafc jmafc authored
View
4 pyrseas/dbobject/column.py
@@ -127,11 +127,11 @@ class ColumnDict(DbObjectDict):
col_description(c.oid, attnum) AS description
FROM pg_attribute JOIN pg_class c ON (attrelid = c.oid)
JOIN pg_namespace ON (relnamespace = pg_namespace.oid)
- JOIN pg_roles ON (nspowner = pg_roles.oid)
LEFT JOIN pg_attrdef ON (attrelid = pg_attrdef.adrelid
AND attnum = pg_attrdef.adnum)
WHERE relkind in ('c', 'r')
- AND (nspname = 'public' OR rolname <> 'postgres')
+ AND (nspname != 'pg_catalog'
+ AND nspname != 'information_schema')
AND attnum > 0
ORDER BY nspname, relname, attnum"""
View
3  pyrseas/dbobject/constraint.py
@@ -259,10 +259,9 @@ class ConstraintDict(DbObjectDict):
obj_description(c.oid, 'pg_constraint') AS description
FROM pg_constraint c
JOIN pg_namespace ON (connamespace = pg_namespace.oid)
- JOIN pg_roles ON (nspowner = pg_roles.oid)
LEFT JOIN pg_class on (conname = relname)
LEFT JOIN pg_am on (relam = pg_am.oid)
- WHERE (nspname = 'public' OR rolname <> 'postgres')
+ WHERE (nspname != 'pg_catalog' AND nspname != 'information_schema')
ORDER BY schema, 2, name"""
def _from_catalog(self):
View
4 pyrseas/dbobject/index.py
@@ -92,10 +92,10 @@ class IndexDict(DbObjectDict):
obj_description (c.oid, 'pg_class') AS description
FROM pg_index JOIN pg_class c ON (indexrelid = c.oid)
JOIN pg_namespace ON (relnamespace = pg_namespace.oid)
- JOIN pg_roles ON (nspowner = pg_roles.oid)
JOIN pg_am ON (relam = pg_am.oid)
WHERE NOT indisprimary
- AND (nspname = 'public' OR rolname <> 'postgres')
+ AND (nspname != 'pg_catalog'
+ AND nspname != 'information_schema')
AND c.relname NOT IN (
SELECT conname FROM pg_constraint
WHERE contype = 'u')
View
5 pyrseas/dbobject/schema.py
@@ -99,8 +99,9 @@ class SchemaDict(DbObjectDict):
query = \
"""SELECT nspname AS name,
obj_description(n.oid, 'pg_namespace') AS description
- FROM pg_namespace n JOIN pg_roles ON (nspowner = pg_roles.oid)
- WHERE nspname = 'public' OR rolname <> 'postgres'
+ FROM pg_namespace n
+ WHERE nspname NOT IN ('pg_catalog', 'information_schema',
+ 'pg_temp_1', 'pg_toast', 'pg_toast_temp_1')
ORDER BY nspname"""
def from_map(self, inmap, newdb):
View
4 pyrseas/dbobject/table.py
@@ -360,9 +360,9 @@ class ClassDict(DbObjectDict):
obj_description(c.oid, 'pg_class') AS description
FROM pg_class c
JOIN pg_namespace ON (relnamespace = pg_namespace.oid)
- JOIN pg_roles ON (nspowner = pg_roles.oid)
WHERE relkind in ('r', 'S', 'v')
- AND (nspname = 'public' OR rolname <> 'postgres')
+ AND (nspname != 'pg_catalog'
+ AND nspname != 'information_schema')
ORDER BY nspname, relname"""
inhquery = \
Please sign in to comment.
Something went wrong with that request. Please try again.