Re: [sqlalchemy] Query before_compile issue

2019-10-28 Thread eric . lemoine
> > today, we have this issue, which I can confirm has existed since version > 1.2 over two years ago, reported for the first time ever here, and then a > day later in https://github.com/sqlalchemy/sqlalchemy/issues/4947 . > Even more funny is that this Issue uses a tenant in the provided

Re: [sqlalchemy] Query before_compile issue

2019-10-25 Thread Mike Bayer
There's a long history, going back over a decade, that issues which have existed for a long time are suddenly reported in twos, that is, within a day of each other. A recent example is just yesterday Alembic reporting both that type comparison *does* check the length of the types, and that it

Re: [sqlalchemy] Query before_compile issue

2019-10-23 Thread eric . lemoine
On Wed, Oct 23, 2019 at 3:16 PM Mike Bayer wrote: > > > On Tue, Oct 22, 2019, at 12:30 PM, eric.lemo...@gmail.com wrote: > > > > > 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

Re: [sqlalchemy] Query before_compile issue

2019-10-23 Thread Mike Bayer
On Tue, Oct 22, 2019, at 12:30 PM, eric.lemo...@gmail.com wrote: > > > >> 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! that worked? wow :) guess you are

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