On Jan 11, 2013, at 1:37 PM, Chris Withers wrote: > On 11/01/2013 15:26, Michael Bayer wrote: >> >>>> what is it looking up ? what's a "myobj" ? >>> >>> An unmapped instance of the mapped class. >> >> yeah you don't want to have unmapped instances of mapped classes lying >> around. > > Why? They're just objects. > > It's really handy having domain objects that can exist without potentially > ever having to know about a database... > > What's the downside of having unmapped objects around?
Beginning to suspect we have a terminology mismatch, an "unmapped" object of a "mapped class" implies you are creating objects from a class before you've mapped the class (that is, called mapper() on the class). Once you've mapped the class, it's no longer possible to get such an object unless you tear down all mappers. So these objects by definition are weird and awkward as they can only be created before your program has completed initialization, or if your program is tearing down mappers which is also not at all appropriate for any application except for extremely specific testing scenarios. If you're using declarative, it should not be possible to have an instance of an unmapped class, for a class that is later mapped, because the mapping is created at the time the class is created (which is as it should be). Perhaps we're not talking about the same thing ? Do you just mean, objects that you aren't actually persisting in the database ? Totally different thing, you're referring to "transient" objects. These are mapped like anything else. http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#sqlalchemy.orm.session.Session.enable_relationship_loading grants some support for that, depending on what you're trying to do. Or session.merge() will load the "persistent" version of an object, given a transient one with a particular primary key. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. 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.
