15 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Is there a way to re...
FromSent OnAttachments
Denis S. Otkidach26 Dec 2007 09:12 
Michael Bayer26 Dec 2007 11:38 
Denis S. Otkidach27 Dec 2007 01:11 
Michael Bayer27 Dec 2007 13:58 
Rick Morrison27 Dec 2007 13:59 
braydon fuller27 Dec 2007 15:01 
Rick Morrison27 Dec 2007 15:06 
Denis S. Otkidach28 Dec 2007 02:49 
Michael Bayer28 Dec 2007 07:25 
Denis S. Otkidach11 Jan 2008 09:30 
Michael Bayer11 Jan 2008 09:41 
Denis S. Otkidach15 Jan 2008 05:20 
Michael Bayer15 Jan 2008 07:54 
Denis S. Otkidach16 Jan 2008 01:43 
Michael Bayer16 Jan 2008 08:41 
Subject:[sqlalchemy] Re: Is there a way to replace object in DB?
From:Denis S. Otkidach (deni@gmail.com)
Date:01/16/2008 01:43:09 AM
List:com.googlegroups.sqlalchemy

On Jan 15, 2008 6:54 PM, Michael Bayer <mike@zzzcomputing.com> wrote:

The last commit fails with: sqlalchemy.exceptions.IntegrityError: (IntegrityError) Referers.objectId may not be NULL u'UPDATE "Referers" SET "objectId"=? WHERE "Referers".id = ?' [None, 1]

right thats because the instance doesnt exist yet. its better for you to just use the straight ahead query.get(), if None then save() approach.

Do you mean obj2 (id of which should go to objectId column in this UPDATE)? If so, why it doesn't exist? It's saved (updated in fact) just several lines above, so it must be both in DB and in session.

The last lines of the original test case for convenience: [...] obj2 = replace(session, ModelObject(1, u'title2')) session.commit()

ref2 = ModelReferer(1, obj2) replace(session, ref2) session.commit()