From 21fbb5e38f04affb8ac4502428672b3a629c2bec Mon Sep 17 00:00:00 2001 From: Jayson Reis Date: Mon, 1 Oct 2018 12:58:46 -0400 Subject: selectinload omit join The "selectin" loader strategy now omits the JOIN in the case of a simple one-to-many load, where it instead relies upon the foreign key columns of the related table in order to match up to primary keys in the parent table. This optimization can be disabled by setting the :paramref:`.relationship.omit_join` flag to False. Many thanks to Jayson Reis for the efforts on this. As part of this change, horizontal shard no longer relies upon the _mapper_zero() method to get the query-bound mapper, instead using the more generalized _bind_mapper() (which will use mapper_zero if no explicit FROM is present). A short check for the particular recursive condition is added to BundleEntity and it no longer assigns itself as the "namespace" to its ColumnEntity objects which creates a reference cycle. Co-authored-by: Mike Bayer Fixes: #4340 Change-Id: I649587e1c07b684ecd63f7d10054cd165891baf4 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/7 --- lib/sqlalchemy/ext/horizontal_shard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sqlalchemy/ext') diff --git a/lib/sqlalchemy/ext/horizontal_shard.py b/lib/sqlalchemy/ext/horizontal_shard.py index 425d28963..f86e4fc93 100644 --- a/lib/sqlalchemy/ext/horizontal_shard.py +++ b/lib/sqlalchemy/ext/horizontal_shard.py @@ -45,7 +45,7 @@ class ShardedQuery(Query): def iter_for_shard(shard_id): context.attributes['shard_id'] = context.identity_token = shard_id result = self._connection_from_session( - mapper=self._mapper_zero(), + mapper=self._bind_mapper(), shard_id=shard_id).execute( context.statement, self._params) -- cgit v1.2.1