shyriak wrote: > > Hi, > I have the following code: > > # tables > datlli_table = Table('DATLLI', meta, autoload = True ) > hstlli_table = Table('HSTLLI', meta, autoload = True ) > > # classes > class Llicencia(object): pass > > # mapers > datlli_mapper = mapper(Llicencia, datlli_table, > primary_key=[datlli_table.c.dni], entity_name='vigent') > hstlli_mapper = mapper(Llicencia, hstlli_table, > primary_key=[hstlli_table.c.dni], entity_name='historic') > > I'm trying to do a session.refresh(llicencia) and I get an error > because the entity_name is None, but the refresh() function not accept > the entity_name as an argument.
yes that is a bug, for which I've added ticket #914. Its quick to fix although I am not at a terminal right now, so as a temporary workaround, just call the "corrected" version of the function: from sqlalchemy.orm import object_session, object_mapper def refresh(instance): object_session(instance).\ query(object_mapper(instance)).\ _get(instance._instance_key, reload=True) release 0.4.2 hasn't gone out yet so this fix will be there. > > session.refresh(llicencia) > File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py", > line 362, in refresh > if self.query(obj.__class__)._get(obj._instance_key, reload=True) > is None: > File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py", > line 295, in query > q = query.Query(_class_mapper(mapper_or_class, > entity_name=entity_name), self, **kwargs) > File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/mapper.py", > line 1875, in class_mapper > raise exceptions.InvalidRequestError("Class '%s' entity name '%s' > has no mapper associated with it" % (class_.__name__, entity_name)) > sqlalchemy.exceptions.InvalidRequestError: Class 'Llicencia' entity > name 'None' has no mapper associated with it > > > There is some other alternative way to do it? > Thanks. > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---