On Oct 2, 2007, at 10:32 AM, Cory Johns wrote:
> > I had originally tried the expunge method, as in the code I had > attached, > but if I just use session.save(policy), I get the aforementioned > exception, > and if I use session.save_or_update(policy) it simply does nothing. > > When using session.merge(policy), I get the following exception: > > File "build\bdist.win32\egg\sqlalchemy\orm\session.py", line 483, > in merge > NameError: global name 'mapperutil' is not defined thats a bug in the exception throw. if you upgrade to 0.4 or the latest trunk of 0.3 its fixed (I recommend 0.4). the error message it would like to show you is: Instance %s has an instance key but is not persisted which means, you are artifically attaching an "_instance_key" to the object but its not actually present in the database. if youre copying over to a new database, remove the "_instance_key" attribute from the object before merging it or saving to the new session; otherwise it thinks no changes are needed. > > Regarding the eager-loading, I understand that the configuration of > the > mappers will be in effect. I meant to inquire as to whether there > was a way > to recursively override the mappers, as this is a different use > than the ORM > was originally intended for, and the usual behavior of lazy-loading > is not > desired here. I considered using the eagerload option, but my ORM has > several levels (eg, Policy contains Insureds which each contain > Addresses) > and it didn't seem like the option would apply all the way down. the eagerload options do apply to multiple levels. in 0.3 you need to specify a separate eagerload() option for each path, i.e. query.options(eagerload('a'), eagerload('a.b'), eagerload('a.b.c')) in 0.4 just use query.options(eagerload_all('a.b.c')) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---