summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/query.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-03-01 16:09:11 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-03-01 16:09:11 -0500
commit79cbd377a62d291103aa0e378f0665e2e09185b2 (patch)
treea9aaebe8daeef5f0b4bb4f229a75ffeaad007051 /lib/sqlalchemy/orm/query.py
parentc5edbc6fdc611d3c812735d83fe056fbb7d113f5 (diff)
downloadsqlalchemy-79cbd377a62d291103aa0e378f0665e2e09185b2.tar.gz
- squash-merge the final row_proc integration branch. this is
a much more modest outcome than what we started with. The work of create_row_processor() for ColumnProperty objects is essentially done at query setup time combined with some lookups in _instance_processor(). - to allow this change for deferred columns, deferred columns no longer search for themselves in the result. If they've been set up as deferred without any explicit directive to undefer them, then this is what was asked for. if we don't do this, then we're stuck with this performance penalty for all deferred columns which in the vast majority of typical use cases (e.g. loading large, legacy tables or tables with many/large very seldom used values) won't be present in the result and won't be accessed at all.
Diffstat (limited to 'lib/sqlalchemy/orm/query.py')
-rw-r--r--lib/sqlalchemy/orm/query.py66
1 files changed, 20 insertions, 46 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 205a5539f..eac2da083 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -3272,25 +3272,21 @@ class _MapperEntity(_QueryEntity):
self.mapper._equivalent_columns)
if query._primary_entity is self:
- _instance = loading.instance_processor(
- self.mapper,
- context,
- result,
- self.path,
- adapter,
- only_load_props=query._only_load_props,
- refresh_state=context.refresh_state,
- polymorphic_discriminator=self._polymorphic_discriminator
- )
+ only_load_props = query._only_load_props
+ refresh_state = context.refresh_state
else:
- _instance = loading.instance_processor(
- self.mapper,
- context,
- result,
- self.path,
- adapter,
- polymorphic_discriminator=self._polymorphic_discriminator
- )
+ only_load_props = refresh_state = None
+
+ _instance = loading._instance_processor(
+ self.mapper,
+ context,
+ result,
+ self.path,
+ adapter,
+ only_load_props=only_load_props,
+ refresh_state=refresh_state,
+ polymorphic_discriminator=self._polymorphic_discriminator
+ )
return _instance, self._label_name
@@ -3311,34 +3307,12 @@ class _MapperEntity(_QueryEntity):
)
)
- if self._with_polymorphic:
- poly_properties = self.mapper._iterate_polymorphic_properties(
- self._with_polymorphic)
- else:
- poly_properties = self.mapper._polymorphic_properties
-
- for value in poly_properties:
- if query._only_load_props and \
- value.key not in query._only_load_props:
- continue
- value.setup(
- context,
- self,
- self.path,
- adapter,
- only_load_props=query._only_load_props,
- column_collection=context.primary_columns
- )
-
- if self._polymorphic_discriminator is not None and \
- self._polymorphic_discriminator \
- is not self.mapper.polymorphic_on:
-
- if adapter:
- pd = adapter.columns[self._polymorphic_discriminator]
- else:
- pd = self._polymorphic_discriminator
- context.primary_columns.append(pd)
+ loading._setup_entity_query(
+ context, self.mapper, self,
+ self.path, adapter, context.primary_columns,
+ with_polymorphic=self._with_polymorphic,
+ only_load_props=query._only_load_props,
+ polymorphic_discriminator=self._polymorphic_discriminator)
def __str__(self):
return str(self.mapper)