Re: [sqlalchemy] testing that a session is committed correctly

2019-06-04 Thread Chris Withers
On 04/06/2019 23:21, Mike Bayer wrote: I'm not following all your code but if there are two sessions in play I'd probably try to avoid that, there should be only one Session you care about. This comes back to something I asked you about on Twitter a while ago: the code under test gets

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-04 Thread Mike Bayer
On Tue, Jun 4, 2019, at 4:33 PM, Chris Withers wrote: > On 04/06/2019 14:49, Mike Bayer wrote: > > > > > > On Tue, Jun 4, 2019, at 2:15 AM, Chris Withers wrote: > >> Now, what I'm trying to test is that I haven't forgotten to include > >> the "with session.transaction". The problem is that,

Re: [sqlalchemy] when does session.transaction come into being?

2019-06-04 Thread Mike Bayer
On Tue, Jun 4, 2019, at 4:34 PM, Chris Withers wrote: > On 04/06/2019 14:47, Mike Bayer wrote: > > > > > > On Tue, Jun 4, 2019, at 3:05 AM, Chris Withers wrote: > >> Hi All, > >> > >> What creates session.transaction? I can't spot get __getattr__ magic, > >> but the only place in the code I

Re: [sqlalchemy] when does session.transaction come into being?

2019-06-04 Thread Chris Withers
On 04/06/2019 14:47, Mike Bayer wrote: On Tue, Jun 4, 2019, at 3:05 AM, Chris Withers wrote: Hi All, What creates session.transaction? I can't spot get __getattr__ magic, but the only place in the code I see it being created is in .begin(...), which has a docstring saying that it should no

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-04 Thread Chris Withers
On 04/06/2019 14:49, Mike Bayer wrote: On Tue, Jun 4, 2019, at 2:15 AM, Chris Withers wrote: Now, what I'm trying to test is that I haven't forgotten to include the "with session.transaction". The problem is that, without the transaction.rollback(), the test passes regardless of whether the

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-04 Thread Mike Bayer
On Tue, Jun 4, 2019, at 2:15 AM, Chris Withers wrote: > Hi All, > > I'm working with the pattern described at > https://docs.sqlalchemy.org/en/13/orm/session_transaction.html#joining-a-session-into-an-external-transaction-such-as-for-test-suites > along with pytest and FastAPI, an async web

Re: [sqlalchemy] when does session.transaction come into being?

2019-06-04 Thread Mike Bayer
On Tue, Jun 4, 2019, at 3:05 AM, Chris Withers wrote: > Hi All, > > What creates session.transaction? I can't spot get __getattr__ magic, > but the only place in the code I see it being created is in .begin(...), > which has a docstring saying that it should no longer be used, so I feel >

Re: [sqlalchemy] Re: Should load_only work with hybrid properties?

2019-06-04 Thread Gmoney
I think I get the idea. That's why the properties with hybrid_property.expression defined are able to work as SQL SELECT fields in the cases where a tuple is returned rather than an ORM model... because you don't have to have a place in _dict__ to put it, it just goes into the tuple. My main

[sqlalchemy] when does session.transaction come into being?

2019-06-04 Thread Chris Withers
Hi All, What creates session.transaction? I can't spot get __getattr__ magic, but the only place in the code I see it being created is in .begin(...), which has a docstring saying that it should no longer be used, so I feel like I must be missing something? cheers, Chris -- SQLAlchemy -

[sqlalchemy] testing that a session is committed correctly

2019-06-04 Thread Chris Withers
Hi All, I'm working with the pattern described at https://docs.sqlalchemy.org/en/13/orm/session_transaction.html#joining-a-session-into-an-external-transaction-such-as-for-test-suites along with pytest and FastAPI, an async web app framework with good support for running blocking code. So,