Thank you,
So I changed my query to a select/for update. then re-added the updated
rows in the transaction, then committed.
works=session.query(Work).filter(tnow-Work.taken<timedelta(minutes=60)).
filter(Work.completed==None).limit(1).with_lockmode(mode='update').all()
When I run two instances of the program, the second one will block on
the query while the first is inside the transaction ('update'). BUT. the
second one should return 1 row when it unblocks because the first
instance only modified 1 row, leaving the other to satisfy the blockers
query. It doesn't return anything when the transaction is released to
the second instance. Peculiar.
I re-run the second instance after that and it then is able to find the
qualifying row. Is that correct behavior? Both program instances are the
same code.
On Sun, 2009-01-11 at 11:04 -0500, Michael Bayer wrote:
>
> On Jan 11, 2009, at 10:44 AM, Darren Govoni wrote:
>
> >
> > Hi,
> > I have 2 records in the database. I made an expression to update only
> > 1 record, but all are getting updated.
> >
> >
> > works=session.query(Work).filter(tnow-
> > Work.taken<timedelta(minutes=15))
> > .filter
> > (Work
> > .completed==None).limit(1).with_lockmode(mode='update').update(values)
> >
> > Shouldn't the above query only perform the update on the limited
> > results
> > of the query?
>
>
> query.update() just issues an UPDATE statement. UPDATE doesn't
> support any kind of LIMITing keywords (maybe MySQL does, but thats not
> SQL). The Query should really be raising an error here without
> emitting any SQL.
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---