On 12/04/2015 10:18 AM, Daniel Thul wrote:
> I configured a relationship to use a bindparam as part of its
> primaryjoin condition.
> This works as long as the relationship is loaded eagerly. As soon as I
> switch to lazy loading it won't resolve the relationship properly.
> I guess this is because the lazy load "forgets" the params that have
> been specified in the original query.
> Is this by design and is there something I can do about it?

The params sent to query.params() are intended to match exactly the SQL
that you're emitting right there.  So it wouldn't make sense for these
params to have influence over future lazy loads, which refer to entirely
different columns and tables which might also have name overlaps with
the query being performed locally.

The recipe at
https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/GlobalFilter
illustrates how to make your own MapperOption which can affect the
parameters used by a Query that's emitted during a lazy load.  The
MapperOption is the only public API right now that has a way to access
these queries.    In theory, you could just make a very simplistic
MapperOption which merely grabs the parameters from the immediate query
within process_query(), and re-applies them in
process_query_conditionally() (which is the method called within the
lazy load sequence).



> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy+unsubscr...@googlegroups.com
> <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
> To post to this group, send email to sqlalchemy@googlegroups.com
> <mailto:sqlalchemy@googlegroups.com>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to