[sqlalchemy] Re: Testing and deprecation of nested transactions

2021-07-30 Thread Federico Caselli
Hi, Have you tried using this pattern from the documentation? I think you can also use that while using only connections https://docs.sqlalchemy.org/en/14/orm/session_transaction.html?highlight=after_transaction_end#joining-a-session-into-an-external-transaction-such-as-for-test-suites On

[sqlalchemy] Re: Testing and deprecation of nested transactions

2021-07-30 Thread 'Jonathan Vanasco' via sqlalchemy
I typically do local developer testing with sqlite3, and the switch the database to postgresql for build/deploy/ci testing in the cloud. For complex tests, I typically use a fresh database "image". e.g. a sqlite file or pgdump output that is tracked in git. This is not the solution you're

Re: [sqlalchemy] prevent (raise exceptions) on bytestring values for non-byte types

2021-07-30 Thread 'Jonathan Vanasco' via sqlalchemy
The second option looks perfect. Will try it! Thank you so much, Simon! On Friday, July 30, 2021 at 1:32:42 PM UTC-4 Simon King wrote: > I can think of a couple of options: > > 1. Create a TypeDecorator for String and Text columns that raises an > error if it sees a bytestring. This will only

Re: [sqlalchemy] prevent (raise exceptions) on bytestring values for non-byte types

2021-07-30 Thread Simon King
I can think of a couple of options: 1. Create a TypeDecorator for String and Text columns that raises an error if it sees a bytestring. This will only flag the error when the session is flushed. 2. Listen for mapper_configured events, iterate over the mapper properties and add an

Re: [sqlalchemy] prevent (raise exceptions) on bytestring values for non-byte types

2021-07-30 Thread 'Jonathan Vanasco' via sqlalchemy
Mike, thanks for replying but go back to vacation. Anyone else: I am thinking more about an event that can be used to catch, perhaps log, all bytes that go in. I only use a few column classes that expect bytestrings, but many that do not. I've gotten every known bug so far, but I'd like to

[sqlalchemy] Testing and deprecation of nested transactions

2021-07-30 Thread Dejan Čabrilo
Hello everyone, I am working on a new project using SqlAlchemy Core 1.4 with Postgresql and wanted to implement the following pattern for my tests: - Before each test I would start a transaction (in a @pytest.fixture(autorun=True)) - Each test may create its own transactions - At the end of