- added "BIGSERIAL" support for postgres table with PGBigInteger/autoincrement
+- fix to MapperExtension create_instance so that entity_name properly associated
+with new instance
0.3.3
- string-based FROM clauses fixed, i.e. select(..., from_obj=["sometext"])
instance = self.extension.create_instance(self, context, row, self.class_)
if instance is EXT_PASS:
instance = self._create_instance(context.session)
+ else:
+ instance._entity_name = self.entity_name
if self.__should_log_debug:
self.__log_debug("_instance(): created new instance %s identity %s" % (mapperutil.instance_str(instance), str(identitykey)))
context.identity_map[identitykey] = instance
return hasattr(object, '_instance_key')
def has_mapper(object):
- """returns True if the given object has a mapper association"""
+ """return True if the given object has had a mapper association set up, either through loading,
+ or via insertion in a session."""
return hasattr(object, '_entity_name')
self.assert_result([u], User,
{'user_id' : 7, 'addresses' : (Address, [{'address_id' : 1}])},
)
-
+
+ def testcreateinstance(self):
+ class Ext(MapperExtension):
+ def create_instance(self, *args, **kwargs):
+ return User()
+ m = mapper(Address, addresses)
+ m = mapper(User, users, extension=Ext(), properties = dict(
+ addresses = relation(Address, lazy=True),
+ ))
+
+ q = create_session().query(m)
+ l = q.select();
+ self.assert_result(l, User, *user_address_result)
+
def testorderby(self):
m = mapper(Address, addresses)