On Nov 19, 2012, at 6:23 PM, Thierry Florac wrote: > As far as I can understand it, I'm globally OK with you but... probably > not completely :-\ > I agree with the fact that SQLAlchemy is not the only package which > takes part into the global transaction, as SA's session is handled by a > Zope transaction manager. And the whole mechanism works globally > perfectly. > What I don't understand is that when: > - I open a session, > - I load a set of objects from the database, > - I update these objects, setting an attribute with it's current value > (I know, said like that it can seems a little silly!),
no problem with that, it produces an event which will cause the flush to do something, but no UPDATE will be emitted in most cases if no net change > - then when the transaction is committed, SA probably knows that the > objects were not really modified, because no UPDATE instruction is > executed; yup > but the SA two-phases transaction is begun, prepared and > aborts on commit because of the given Oracle error. the first news to me here is that two-phase commit works with cx_oracle and SQLAlchemy. I've never seen it work or been able to test it. I'm also not familiar with this behavior. Oracle won't allow PREPARE ? Can I see stack trace + full ORA message ? the error code is especially significant, had no idea this was an Oracle error. Also, is this two-phase as implemented by SQLAlchemy itself ? You have "twophase=True" with sessionmaker() ? I hope zope.sqlalchemy isn't hardcoding that.. > - but if I add a check to update objects attribute only if the new > value is different from the actual one, the SA transaction is begun > on my first request, but not prepared nor committed, and no error is > raised, doesn't sound right. If SA starts a transaction, it will also be PREPARE/COMMITTED because zope.sqlalchemy is calling commit() on the Session. You can't be just leaving that new transaction hanging open. Or it might be rolled back, but its one or the other. -- 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.
