Re: [sqlalchemy] Query before_compile issue

2019-10-22 Thread eric . lemoine
it sounds like you should use a bound parameter with a lambda inside of it, > there's not an explicit "on lazyload" hook at the moment. > Yep, that seems to be doing the job! -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code,

Re: [sqlalchemy] Query before_compile issue

2019-10-22 Thread Mike Bayer
On Tue, Oct 22, 2019, at 12:08 PM, eric.lemo...@gmail.com wrote: > > > On Tue, Oct 22, 2019 at 5:59 PM Mike Bayer wrote: >> >> >> On Tue, Oct 22, 2019, at 11:58 AM, Eric Lemoine wrote: >>> >>> > The first time before_compile is called twice, one call for the SELECT > FROM "user"

Re: [sqlalchemy] Query before_compile issue

2019-10-22 Thread eric . lemoine
On Tue, Oct 22, 2019 at 5:59 PM Mike Bayer wrote: > > > On Tue, Oct 22, 2019, at 11:58 AM, Eric Lemoine wrote: > > > > The first time before_compile is called twice, one call for the SELECT FROM > "user" query, and another call for the SELECT FROM "address" query. But the > second time

Re: [sqlalchemy] Query before_compile issue

2019-10-22 Thread Mike Bayer
On Tue, Oct 22, 2019, at 11:58 AM, Eric Lemoine wrote: > > >>> The first time before_compile is called twice, one call for the SELECT FROM >>> "user" query, and another call for the SELECT FROM "address" query. But the >>> second time before_compile is called only once. It's called for the

Re: [sqlalchemy] Query before_compile issue

2019-10-22 Thread Eric Lemoine
> The first time before_compile is called twice, one call for the SELECT FROM > "user" query, and another call for the SELECT FROM "address" query. But the > second time before_compile is called only once. It's called for the SELECT > FROM "user" query, but not for the SELECT FROM "addresses"

Re: [sqlalchemy] Query before_compile issue

2019-10-22 Thread Mike Bayer
On Tue, Oct 22, 2019, at 9:36 AM, Eric Lemoine wrote: > Hi > > I want to use the FilteredQuery pattern [1], but I am facing a problem > related to SQLAlchemy not calling "before_compile" as often as I'd expect it. > > Here's a simple example: > > @event.listens_for(Query, "before_compile",

[sqlalchemy] Query before_compile issue

2019-10-22 Thread Eric Lemoine
Hi I want to use the FilteredQuery pattern [1], but I am facing a problem related to SQLAlchemy not calling "before_compile" as often as I'd expect it. Here's a simple example: @event.listens_for(Query, "before_compile", retval=True) def before_compile(query): print("X before_compiled