Re: [sqlalchemy] Primary key set on object after rollback

2018-09-25 Thread Doug Miller
I think my issue is that before the commit/rollback Alice.id is None but after Alice.id is set to some integer. I understand the object is transient but I wish that the primary key field was not modified in this way because if I want to try to reinsert Alice in a new transaction I have to write

Re: [sqlalchemy] Primary key set on object after rollback

2018-09-25 Thread Mike Bayer
defintions of transient, persistent: https://docs.sqlalchemy.org/en/latest/orm/session_state_management.html#quickie-intro-to-object-states note the objects have None for inspect(object).key, which is the actual database identity. from sqlalchemy import inspect assert inspect(alice).key is None

Re: [sqlalchemy] Primary key set on object after rollback

2018-09-25 Thread Mike Bayer
On Tue, Sep 25, 2018 at 7:09 PM Doug Miller wrote: > > I've noticed that if a transaction fails midway through, objects that already > have been inserted will have their primary keys set, even after rolling back. > > Partial snippet below: > > - > > class User(Base): > id =

Re: [sqlalchemy] Hybrid property with subquery

2018-09-25 Thread Mike Bayer
On Mon, Sep 24, 2018 at 12:22 PM YKdvd wrote: > > I have an ORM setup with a "departments_milestones" table ("dm", > DepartmentMilestone objects), with "department_id" and "seqOrder" Fields. > Each department has a few records in this table, ordered within the > department by "seqOrder" (so

Re: File logger fails when used with a Gunicorn/Pyramid .ini file.

2018-09-25 Thread jens . troeger
Huh… I use the -c option: ./bin/alembic -c proj-localhost.ini upgrade head Jens On Monday, September 24, 2018 at 11:21:42 PM UTC+10, Mike Bayer wrote: > > > Looking at the source code, we already have "here": > > if self.config_file_name: > here =

[sqlalchemy] Primary key set on object after rollback

2018-09-25 Thread Doug Miller
I've noticed that if a transaction fails midway through, objects that already have been inserted will have their primary keys set, even after rolling back. Partial snippet below: - class User(Base): id = Column(Integer, primary_key=True) name = Column(String(80), unique=True,

[sqlalchemy] server_default = 'now() at time zone \'utc\'' error

2018-09-25 Thread Cevin Cheung
got sql = "create table test( col timestamptz default ' now() at time zone ''utc'' ' ) -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See