diff options
author | Rodrigo Menezes <rodrigo.menezes@moat.com> | 2014-09-03 16:38:43 -0400 |
---|---|---|
committer | Rodrigo Menezes <rodrigo.menezes@moat.com> | 2014-09-03 16:38:43 -0400 |
commit | fbd2d70a5cfd7b5c219c51cb5b7866c4ab89cece (patch) | |
tree | 996181dbb3fcade0e1dbfad163d01d3cb547580d /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | d39be884321d0afbae7ef3da556382b53fef8060 (diff) | |
download | sqlalchemy-fbd2d70a5cfd7b5c219c51cb5b7866c4ab89cece.tar.gz |
Fixing some pep8s and adding get_foreign_tables.
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 40b2f60ae..69ae6cfed 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -2086,7 +2086,7 @@ class PGDialect(default.DefaultDialect): s = """ SELECT relname FROM pg_class c - WHERE relkind = 'v' + WHERE relkind IN ('m', v') AND '%(schema)s' = (select nspname from pg_namespace n where n.oid = c.relnamespace) """ % dict(schema=current_schema) @@ -2099,6 +2099,24 @@ class PGDialect(default.DefaultDialect): return view_names @reflection.cache + def get_foreign_table_names(self, connection, schema=None, **kw): + if schema is not None: + current_schema = schema + else: + current_schema = self.default_schema_name + + result = connection.execute( + sql.text("SELECT relname FROM pg_class c " + "WHERE relkind = 'f' " + "AND '%s' = (select nspname from pg_namespace n " + "where n.oid = c.relnamespace) " % + current_schema, + typemap={'relname': sqltypes.Unicode} + ) + ) + return [row[0] for row in result] + + @reflection.cache def get_view_definition(self, connection, view_name, schema=None, **kw): if schema is not None: current_schema = schema @@ -2434,7 +2452,7 @@ class PGDialect(default.DefaultDialect): # cast indkey as varchar since it's an int2vector, # returned as a list by some drivers such as pypostgresql - + IDX_SQL = """ SELECT i.relname as relname, |