diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-28 20:29:08 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-28 20:29:08 +0000 |
commit | 72b9be719fae32dc19793989d505d9c92f40b739 (patch) | |
tree | e6a70b2cb20622d77b723b62a2a22382aadf27c9 /lib/sqlalchemy/sql/util.py | |
parent | f892d1a3fe8e349d1008bee51be5633dbfbf1189 (diff) | |
download | sqlalchemy-72b9be719fae32dc19793989d505d9c92f40b739.tar.gz |
- Fixed an obscure issue whereby a joined-table subclass
with a self-referential eager load on the base class
would populate the related object's "subclass" table with
data from the "subclass" table of the parent.
[ticket:1485]
Diffstat (limited to 'lib/sqlalchemy/sql/util.py')
-rw-r--r-- | lib/sqlalchemy/sql/util.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index 27ae3e624..9be405e21 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -498,11 +498,12 @@ class ColumnAdapter(ClauseAdapter): adapted_row() factory. """ - def __init__(self, selectable, equivalents=None, chain_to=None, include=None, exclude=None): + def __init__(self, selectable, equivalents=None, chain_to=None, include=None, exclude=None, adapt_required=False): ClauseAdapter.__init__(self, selectable, equivalents, include, exclude) if chain_to: self.chain(chain_to) self.columns = util.populate_column_dict(self._locate_col) + self.adapt_required = adapt_required def wrap(self, adapter): ac = self.__class__.__new__(self.__class__) @@ -530,6 +531,16 @@ class ColumnAdapter(ClauseAdapter): # anonymize labels in case they have a hardcoded name if isinstance(c, expression._Label): c = c.label(None) + + # adapt_required indicates that if we got the same column + # back which we put in (i.e. it passed through), + # it's not correct. this is used by eagerloading which + # knows that all columns and expressions need to be adapted + # to a result row, and a "passthrough" is definitely targeting + # the wrong column. + if self.adapt_required and c is col: + return None + return c def adapted_row(self, row): |