Fixed #30644 -- Made introspection use pg_table_is_visible() instead of filtering by public schema on PostgreSQL.
This commit is contained in:
parent
842fd620ff
commit
c6581a40be
|
@ -99,10 +99,9 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
JOIN pg_attrdef ad ON ad.oid = d.objid AND d.classid = 'pg_attrdef'::regclass
|
JOIN pg_attrdef ad ON ad.oid = d.objid AND d.classid = 'pg_attrdef'::regclass
|
||||||
JOIN pg_attribute col ON col.attrelid = ad.adrelid AND col.attnum = ad.adnum
|
JOIN pg_attribute col ON col.attrelid = ad.adrelid AND col.attnum = ad.adnum
|
||||||
JOIN pg_class tbl ON tbl.oid = ad.adrelid
|
JOIN pg_class tbl ON tbl.oid = ad.adrelid
|
||||||
JOIN pg_namespace n ON n.oid = tbl.relnamespace
|
|
||||||
WHERE s.relkind = 'S'
|
WHERE s.relkind = 'S'
|
||||||
AND d.deptype in ('a', 'n')
|
AND d.deptype in ('a', 'n')
|
||||||
AND n.nspname = 'public'
|
AND pg_catalog.pg_table_is_visible(tbl.oid)
|
||||||
AND tbl.relname = %s
|
AND tbl.relname = %s
|
||||||
""", [table_name])
|
""", [table_name])
|
||||||
return [
|
return [
|
||||||
|
@ -125,7 +124,11 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
LEFT JOIN pg_class c2 ON con.confrelid = c2.oid
|
LEFT JOIN pg_class c2 ON con.confrelid = c2.oid
|
||||||
LEFT JOIN pg_attribute a1 ON c1.oid = a1.attrelid AND a1.attnum = con.conkey[1]
|
LEFT JOIN pg_attribute a1 ON c1.oid = a1.attrelid AND a1.attnum = con.conkey[1]
|
||||||
LEFT JOIN pg_attribute a2 ON c2.oid = a2.attrelid AND a2.attnum = con.confkey[1]
|
LEFT JOIN pg_attribute a2 ON c2.oid = a2.attrelid AND a2.attnum = con.confkey[1]
|
||||||
WHERE c1.relname = %s AND con.contype = 'f'
|
WHERE
|
||||||
|
c1.relname = %s AND
|
||||||
|
con.contype = 'f' AND
|
||||||
|
c1.relnamespace = c2.relnamespace AND
|
||||||
|
pg_catalog.pg_table_is_visible(c1.oid)
|
||||||
""", [table_name])
|
""", [table_name])
|
||||||
return cursor.fetchall()
|
return cursor.fetchall()
|
||||||
|
|
||||||
|
@ -157,9 +160,8 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
cl.reloptions
|
cl.reloptions
|
||||||
FROM pg_constraint AS c
|
FROM pg_constraint AS c
|
||||||
JOIN pg_class AS cl ON c.conrelid = cl.oid
|
JOIN pg_class AS cl ON c.conrelid = cl.oid
|
||||||
JOIN pg_namespace AS ns ON cl.relnamespace = ns.oid
|
WHERE cl.relname = %s AND pg_catalog.pg_table_is_visible(cl.oid)
|
||||||
WHERE ns.nspname = %s AND cl.relname = %s
|
""", [table_name])
|
||||||
""", ["public", table_name])
|
|
||||||
for constraint, columns, kind, used_cols, options in cursor.fetchall():
|
for constraint, columns, kind, used_cols, options in cursor.fetchall():
|
||||||
constraints[constraint] = {
|
constraints[constraint] = {
|
||||||
"columns": columns,
|
"columns": columns,
|
||||||
|
@ -198,7 +200,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
LEFT JOIN pg_class c2 ON idx.indexrelid = c2.oid
|
LEFT JOIN pg_class c2 ON idx.indexrelid = c2.oid
|
||||||
LEFT JOIN pg_am am ON c2.relam = am.oid
|
LEFT JOIN pg_am am ON c2.relam = am.oid
|
||||||
LEFT JOIN pg_attribute attr ON attr.attrelid = c.oid AND attr.attnum = idx.key
|
LEFT JOIN pg_attribute attr ON attr.attrelid = c.oid AND attr.attnum = idx.key
|
||||||
WHERE c.relname = %s
|
WHERE c.relname = %s AND pg_catalog.pg_table_is_visible(c.oid)
|
||||||
) s2
|
) s2
|
||||||
GROUP BY indexname, indisunique, indisprimary, amname, exprdef, attoptions;
|
GROUP BY indexname, indisunique, indisprimary, amname, exprdef, attoptions;
|
||||||
""", [table_name])
|
""", [table_name])
|
||||||
|
|
Loading…
Reference in New Issue