diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-24 16:25:20 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-24 16:25:20 -0400 |
commit | 1fe06a551c28a6e0886f96334deebdee68d9fff9 (patch) | |
tree | 8ed3a735d220cc8a95d4067b331d64e01bc51d03 /lib/sqlalchemy/engine/reflection.py | |
parent | f69ccd193b5f1bfe4f2f50e93fe912ceac1af66e (diff) | |
parent | 3cbe90efbebd38c570a137d2801753e3aa55823b (diff) | |
download | sqlalchemy-1fe06a551c28a6e0886f96334deebdee68d9fff9.tar.gz |
- [feature] Inspector.get_primary_keys() is
deprecated; use Inspector.get_pk_constraint().
Courtesy Diana Clarke. [ticket:2422]
- restored default get_primary_keys()/get_pk_constraint() wrapper
to help maintain compatibility with third party dialects
created against 0.6 or 0.7
Diffstat (limited to 'lib/sqlalchemy/engine/reflection.py')
-rw-r--r-- | lib/sqlalchemy/engine/reflection.py | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py index 4ad3595c3..13a7e1b88 100644 --- a/lib/sqlalchemy/engine/reflection.py +++ b/lib/sqlalchemy/engine/reflection.py @@ -26,10 +26,11 @@ methods such as get_table_names, get_columns, etc. import sqlalchemy from sqlalchemy import exc, sql +from sqlalchemy import schema as sa_schema from sqlalchemy import util -from sqlalchemy.util import topological from sqlalchemy.types import TypeEngine -from sqlalchemy import schema as sa_schema +from sqlalchemy.util import deprecated +from sqlalchemy.util import topological from sqlalchemy import inspection from sqlalchemy.engine.base import Connectable @@ -233,6 +234,8 @@ class Inspector(object): col_def['type'] = coltype() return col_defs + @deprecated('0.7', 'Call to deprecated method get_primary_keys.' + ' Use get_pk_constraint instead.') def get_primary_keys(self, table_name, schema=None, **kw): """Return information about primary keys in `table_name`. @@ -240,11 +243,9 @@ class Inspector(object): primary key information as a list of column names. """ - pkeys = self.dialect.get_primary_keys(self.bind, table_name, schema, - info_cache=self.info_cache, - **kw) - - return pkeys + return self.dialect.get_pk_constraint(self.bind, table_name, schema, + info_cache=self.info_cache, + **kw)['constrained_columns'] def get_pk_constraint(self, table_name, schema=None, **kw): """Return information about primary key constraint on `table_name`. @@ -259,12 +260,10 @@ class Inspector(object): optional name of the primary key constraint. """ - pkeys = self.dialect.get_pk_constraint(self.bind, table_name, schema, + return self.dialect.get_pk_constraint(self.bind, table_name, schema, info_cache=self.info_cache, **kw) - return pkeys - def get_foreign_keys(self, table_name, schema=None, **kw): """Return information about foreign_keys in `table_name`. @@ -293,10 +292,9 @@ class Inspector(object): """ - fk_defs = self.dialect.get_foreign_keys(self.bind, table_name, schema, + return self.dialect.get_foreign_keys(self.bind, table_name, schema, info_cache=self.info_cache, **kw) - return fk_defs def get_indexes(self, table_name, schema=None, **kw): """Return information about indexes in `table_name`. @@ -317,10 +315,9 @@ class Inspector(object): other options passed to the dialect's get_indexes() method. """ - indexes = self.dialect.get_indexes(self.bind, table_name, + return self.dialect.get_indexes(self.bind, table_name, schema, info_cache=self.info_cache, **kw) - return indexes def reflecttable(self, table, include_columns, exclude_columns=()): """Given a Table object, load its internal constructs based on introspection. |