Re: [sqlalchemy] raise error on insert/update PK?

2018-01-03 Thread Tim Chen
Thanks so much! Really appreciate the example. On Wednesday, January 3, 2018 at 3:46:47 PM UTC-5, Mike Bayer wrote: > > On Wed, Jan 3, 2018 at 1:18 PM, Tim Chen <timc...@gmail.com > > wrote: > > Let's say I'm using a uuid PK for my models with a

[sqlalchemy] raise error on insert/update PK?

2018-01-03 Thread Tim Chen
Let's say I'm using a uuid PK for my models with a ` server_default` set to `gen_random_uuid()` (in PostgreSQL). Is there a way to ensure the server_default value? I would like to catch any INSERT or UPDATE statements that set the PK value and raise an error if possible. -- SQLAlchemy -

Re: [sqlalchemy] creating objects in merge() does not set primary key

2018-01-02 Thread Tim Chen
#sqlalchemy.orm.session.Session.merge On Tuesday, January 2, 2018 at 11:47:06 AM UTC-5, Mike Bayer wrote: > > On Tue, Jan 2, 2018 at 11:44 AM, Tim Chen <timc...@gmail.com > > wrote: > > Hrmm, that's not what I'm getting. Maybe I'm misunderstanding something > - > > here's

Re: [sqlalchemy] creating objects in merge() does not set primary key

2018-01-02 Thread Tim Chen
() session.add(user) session.commit() assert user.id assert user.profile.id test_add() test_merge() On Monday, January 1, 2018 at 9:49:55 PM UTC-5, Mike Bayer wrote: > > On Mon, Jan 1, 2018 at 9:18 PM, Tim Chen <timc...@gmail.com > > wrote: > > When I merge() an o

[sqlalchemy] creating objects in merge() does not set primary key

2018-01-01 Thread Tim Chen
When I merge() an object without a PK, I expect similar behavior to add(), in that the autogenerated PK is returned and set on the object. Is that not expected behavior? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code,

Re: [sqlalchemy] nested correlated exists subquery ?

2016-07-08 Thread Tim Chen
if that needs help with the correlation then we'd add some correlate() > calls, but it shouldn't, since the FROM nesting here is clear. > On 07/08/2016 03:21 AM, Tim Chen wrote: > > Hi, I'm wondering what the correct syntax is for a nested correlated > > exists subquery? > >

[sqlalchemy] nested correlated exists subquery ?

2016-07-08 Thread Tim Chen
Hi, I'm wondering what the correct syntax is for a nested correlated exists subquery? I have Message and Engagement declarative tables and here is the query i'm trying to replicate: select * from message m where exists ( select 1 from engagement e where m.engagement_id = e.id and exists