Re: [Sqlalchemy-tickets] [sqlalchemy] #2887: subqueryload query invokes ahead of parent loader init
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-12-11 17:45:28
|
#2887: subqueryload query invokes ahead of parent loader init, can cause conflicts
------------------------------+-------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.8.xx
Component: orm | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: in progress |
------------------------------+-------------------------------
Comment (by zzzeek):
we can address that issue by adding a "make sure we run the subq loader"
function like this:
{{{
#!diff
@@ -962,7 +969,13 @@ class SubqueryLoader(AbstractRelationshipLoader):
state.get_impl(self.key).\
set_committed_value(state, dict_, collection)
- return load_collection_from_subq, None, None
+ def _make_sure_its_loaded(state, dict_, row):
+ collections.get(
+ tuple([row[col] for col in local_cols]),
+ ()
+ )
+
+ return load_collection_from_subq, None, None,
_make_sure_its_loaded
def _create_scalar_loader(self, collections, local_cols):
def load_scalar_from_subq(state, dict_, row):
@@ -980,7 +993,13 @@ class SubqueryLoader(AbstractRelationshipLoader):
state.get_impl(self.key).\
set_committed_value(state, dict_, scalar)
- return load_scalar_from_subq, None, None
+ def _make_sure_its_loaded(state, dict_, row):
+ collections.get(
+ tuple([row[col] for col in local_cols]),
+ ()
+ )
+
+ return load_scalar_from_subq, None, None, _make_sure_its_loaded
}}}
additional issues remain with some self-referential loading
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2887#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|