- Fixed bug whereby changing a primary key attribute on an
entity where the attribute's previous value had been expired
would produce an error upon flush(). [ticket:1151]
+
+ - Fixed custom instrumentation bug whereby get_instance_dict()
+ was not called for newly constructed instances not loaded
+ by the ORM.
- Session.delete() adds the given object to the session if
not already present. This was a regression bug from 0.4
if self.has_state(instance):
return False
else:
- new_state = self.instance_state_factory(instance, self)
- self.install_state(instance, new_state)
- return new_state
+ return self.setup_instance(instance)
def has_parent(self, state, key, optimistic=False):
"""TODO"""
clear_mappers()
attributes._install_lookup_strategy(util.symbol('native'))
+ def test_instance_dict(self):
+ class User(MyClass):
+ pass
+
+ attributes.register_class(User)
+ attributes.register_attribute(User, 'user_id', uselist = False, useobject=False)
+ attributes.register_attribute(User, 'user_name', uselist = False, useobject=False)
+ attributes.register_attribute(User, 'email_address', uselist = False, useobject=False)
+
+ u = User()
+ u.user_id = 7
+ u.user_name = 'john'
+ u.email_address = 'lala@123.com'
+ self.assert_(u.__dict__ == {'_my_state':u._my_state, '_goofy_dict':{'user_id':7, 'user_name':'john', 'email_address':'lala@123.com'}})
+
def test_basic(self):
for base in (object, MyBaseClass, MyClass):
class User(base):