Re: [sqlalchemy] Invalidated Collection

2021-02-04 Thread Christian Henning
Thanks, Mike! I have some studying to do... On Wednesday, February 3, 2021 at 6:42:17 PM UTC-5 Mike Bayer wrote: > > > On Wed, Feb 3, 2021, at 6:23 PM, Christian Henning wrote: > > Hi Mike, > > thanks for your advice! I'll make the changes. > > But let me ask you one thing. My classmethod create(

Re: [sqlalchemy] Invalidated Collection

2021-02-03 Thread Mike Bayer
On Wed, Feb 3, 2021, at 6:23 PM, Christian Henning wrote: > Hi Mike, > > thanks for your advice! I'll make the changes. > > But let me ask you one thing. My classmethod create() is but more complex > than I have posted. It's meant to catch IntegrityError so that unique > constraints are enfor

Re: [sqlalchemy] Invalidated Collection

2021-02-03 Thread Christian Henning
Hi Mike, thanks for your advice! I'll make the changes. But let me ask you one thing. My classmethod create() is but more complex than I have posted. It's meant to catch IntegrityError so that unique constraints are enforced. Image a User table has a "unique" constraint on the name. When I try

Re: [sqlalchemy] Invalidated Collection

2021-02-03 Thread Mike Bayer
the session.commit() method expires all attributes by default: https://docs.sqlalchemy.org/en/13/orm/session_basics.html#committing your code is organized in an unusual way such that transactions are being committed inside of attribute assignment operations: jack.addresses.append(Address.cr

[sqlalchemy] Invalidated Collection

2021-02-03 Thread Christian Henning
I don't understand why SQLAlchemy gives me the following warning: SAWarning: This collection has been invalidated. util.warn("This collection has been invalidated.") Here is a minimal code example: - - import sqlalchemy print(sqlalchemy.__version__) from sqlal