function at the moment
- some fixes to between(), column.between() to propigate typing
information better [ticket:202]
-
+- if an object fails to be constructed, is not added to the
+session [ticket:203]
0.2.2
- big improvements to polymorphic inheritance behavior, enabling it
session._register_new(self)
if oldinit is not None:
- oldinit(self, *args, **kwargs)
+ try:
+ oldinit(self, *args, **kwargs)
+ except:
+ if session is not None:
+ session.expunge(self)
+ raise
# override oldinit, insuring that its not already a Mapper-decorated init method
if oldinit is None or not hasattr(oldinit, '_sa_mapper_init'):
init._sa_mapper_init = True
self.assert_(u.user_name == 'jack')
self.assert_(a not in u.addresses)
+ def testbadconstructor(self):
+ """tests that if the construction of a mapped class fails, the instnace does not get placed in the session"""
+ class Foo(object):
+ def __init__(self, one, two):
+ pass
+ mapper(Foo, users)
+ sess = create_session()
+ try:
+ Foo('one', _sa_session=sess)
+ assert False
+ except:
+ assert len(list(sess)) == 0
+ try:
+ Foo('one')
+ assert False
+ except TypeError, e:
+ pass
+
def testrefresh_lazy(self):
"""tests that when a lazy loader is set as a trigger on an object's attribute (at the attribute level, not the class level), a refresh() operation doesnt fire the lazy loader or create any problems"""
s = create_session()