diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-20 01:16:16 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-20 01:16:16 +0000 |
commit | 865e2aaa19a1c4597b25c4ac0a090f7f3938bc20 (patch) | |
tree | 0da15458878e7450221e9c85be963a5d9a1946f5 /lib/sqlalchemy/mapping/properties.py | |
parent | 8004a63d72b99a8e6c68aa1f7b4c637f577cf369 (diff) | |
download | sqlalchemy-865e2aaa19a1c4597b25c4ac0a090f7f3938bc20.tar.gz |
a few tweaks and the polymorph example can also use eager loading
Diffstat (limited to 'lib/sqlalchemy/mapping/properties.py')
-rw-r--r-- | lib/sqlalchemy/mapping/properties.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sqlalchemy/mapping/properties.py b/lib/sqlalchemy/mapping/properties.py index 6b8c13793..6a073f0a6 100644 --- a/lib/sqlalchemy/mapping/properties.py +++ b/lib/sqlalchemy/mapping/properties.py @@ -785,10 +785,18 @@ class EagerLoader(PropertyLoader): def _instance(self, row, imap, result_list=None): """gets an instance from a row, via this EagerLoader's mapper.""" + # since the EagerLoader makes an Alias of its mapper's table, + # we translate the actual result columns back to what they + # would normally be into a "virtual row" which is passed to the child mapper. + # that way the mapper doesnt have to know about the modified column name + # (neither do any MapperExtensions). The row is keyed off the Column object + # (which is what mappers use) as well as its "label" (which might be what + # user-defined code is using) fakerow = util.DictDecorator(row) for c in self.eagertarget.c: parent = self.target._get_col_by_original(c.original) fakerow[parent] = row[c] + fakerow[parent._label] = row[c] row = fakerow return self.mapper._instance(row, imap, result_list) |