diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2017-08-24 11:00:50 -0400 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@awstats.zzzcomputing.com> | 2017-08-24 11:00:50 -0400 |
| commit | 887fb3ebaad20847edc752f5fcf072ace947d56a (patch) | |
| tree | 4165c399255f0cb15df9d121769f4f14b9f1bc40 /lib/sqlalchemy | |
| parent | e33cff44b5822a22c540d316151699203a1fff52 (diff) | |
| parent | 827b495b8bc1c6c32ef7a872b7995abcb31a14d6 (diff) | |
| download | sqlalchemy-887fb3ebaad20847edc752f5fcf072ace947d56a.tar.gz | |
Merge "Ensure col is not None when retrieving quick populators"
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/loading.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py index e4aea3994..cbc995489 100644 --- a/lib/sqlalchemy/orm/loading.py +++ b/lib/sqlalchemy/orm/loading.py @@ -322,9 +322,24 @@ def _instance_processor( # be present in some unexpected way. populators["expire"].append((prop.key, False)) else: + getter = None + # the "adapter" can be here via different paths, + # e.g. via adapter present at setup_query or adapter + # applied to the query afterwards via eager load subquery. + # If the column here + # were already a product of this adapter, sending it through + # the adapter again can return a totally new expression that + # won't be recognized in the result, and the ColumnAdapter + # currently does not accommodate for this. OTOH, if the + # column were never applied through this adapter, we may get + # None back, in which case we still won't get our "getter". + # so try both against result._getter(). See issue #4048 if adapter: - col = adapter.columns[col] - getter = result._getter(col, False) + adapted_col = adapter.columns[col] + if adapted_col is not None: + getter = result._getter(adapted_col, False) + if not getter: + getter = result._getter(col, False) if getter: populators["quick"].append((prop.key, getter)) else: |
