I complained recently about problems with things disappearing from an
in-memory sqlite database.  It appears that my problems were actually
symptoms of something else: that, so far as I can see, doing a

   transaction.commit()

when SQLAlchemy is active does *not* first do a session().commit()!
This means that the following sequence in a test suite:

   >>> p = Person(name='Brandon')
   >>> s = session()
   >>> s.add(p)
   >>> transaction.commit()

   >>> s.attribute = 'an illegal value'
   Traceback:
      ...
   Exception: the database does not allow that attribute to have that value
   >>> transaction.rollback()

Instead, to make this work, one has to write the first stanza as:

   >>> p = Person(name='Brandon')
   >>> s = session()
   >>> s.add(p)
   >>> s.flush()  # Sheesh
   >>> transaction.commit()

Could zope.sqlalchemy be improved so that, on transaction commit, the
current SQLAlchemy session is first flushed before being committed?

-- 
Brandon Craig Rhodes   [EMAIL PROTECTED]   http://rhodesmill.org/brandon
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to