diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-12 17:14:34 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-12 17:14:34 -0500 |
commit | 345de2ee1dfb12c6314144c2b7ed6fb4a7a3cb7c (patch) | |
tree | 4540d2c510e215123f5cbdb724bd34f889fa6673 /lib/sqlalchemy/schema.py | |
parent | ba0fb069d5e76e4fe3365765caa1239bfd7371cc (diff) | |
download | sqlalchemy-345de2ee1dfb12c6314144c2b7ed6fb4a7a3cb7c.tar.gz |
- [bug] Fixed bug in new "autoload_replace" flag
which would fail to preserve the primary
key constraint of the reflected table.
[ticket:2402]
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r-- | lib/sqlalchemy/schema.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index c183e4385..83a6e0f37 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -369,9 +369,12 @@ class Table(SchemaItem, expression.TableClause): # allow user-overrides self._init_items(*args) - def _autoload(self, metadata, autoload_with, include_columns, exclude_columns=None): + def _autoload(self, metadata, autoload_with, include_columns, exclude_columns=()): if self.primary_key.columns: - PrimaryKeyConstraint()._set_parent_with_dispatch(self) + PrimaryKeyConstraint(*[ + c for c in self.primary_key.columns + if c.key in exclude_columns + ])._set_parent_with_dispatch(self) if autoload_with: autoload_with.run_callable( @@ -424,7 +427,7 @@ class Table(SchemaItem, expression.TableClause): if not autoload_replace: exclude_columns = [c.name for c in self.c] else: - exclude_columns = None + exclude_columns = () self._autoload(self.metadata, autoload_with, include_columns, exclude_columns) self._extra_kwargs(**kwargs) |