Le Mon, 19 Nov 2012 10:23:14 -0500,
  Michael Bayer <[email protected]> a écrit:

> On Nov 19, 2012, at 8:10 AM, Thierry Florac wrote:
> 
> > Hi,
> > 
> > I'm using SQLALchemy (currently 0.7.3 in this project, also tested
> > with 0.7.9) with cx_Oracle-5.1.1 in a Zope3 project. SQLAlchemy
> > transactions are handled in two-phase with ZopeTransactionExtension.
> > 
> > My problem is quite simple : in a form, I can order several items
> > which updates an "index" attribute. Problem : if no ordering is
> > done and "save" button is clicked, I get the given "transaction
> > does not exist" error. If I just add a control in my form handling
> > method to set a new index value only if it was modified (instead of
> > setting the attribute with the same value), everything is fine.
> > 
> > So my question is : is it normal that setting objects attributes
> > without changing their actual value generates this error ?
> 
> That's not a SQLAlchemy error.   SQLAlchemy's Session has no linkage
> between its notion of a transaction and whether or not any state was
> changed.  If you're working with a Session that hasn't accessed the
> database, there won't be any actual database transaction present
> until that happens.  But that isn't an error condition.
> 
> You might want to check with the zope.transaction folks as well as
> with whatever web framework you're using.

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!),
 - then when the transaction is committed, SA probably knows that the
   objects were not really modified, because no UPDATE instruction is
   executed; but the SA two-phases transaction is begun, prepared and
   aborts on commit because of the given Oracle error.
 - 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,
 - and of course, if I really modify any object of my set, the
   transaction is begun, prepared and committed without any error...

Any idea ?

Best regards,
Thierry

-- 
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.

Reply via email to