Worked perfectly. Thanks a lot for your quick answer and so great software.
Le jeudi 24 mai 2012 16:45:50 UTC+2, Michael Bayer a écrit : > > > On May 24, 2012, at 10:02 AM, pr64 wrote: > > Hi, > > For some reason, I need to access my sqlite database through an API which > encapsulates the sqlalchemy stuff. > In my api methods, the typical sequence is: > > 1. get a session from the session maker > 2. query/commit the db using this session > 3. return the queried/commited object and close the session > > From the caller side, the returned object may have expired but i don't > care (I configure my session maker with expire_on_commit=False) > > This works fine, ie the object is detached from the db but immediate > attributes are available from reading without any call to a hidden > sqlalchemy refresh. > > If I want to access linked tables, I just implement it with joinedloads > within my api and again the caller can read related attributes. > > The problem comes with inherited tables. I would like to be able to tell > sqlalchemy to automatically load the child instead of loading the base > class (and after issueing a refresh). Here's a sample > code:http://pastebin.com/SyKmh9Ac > > Line 131 works fine since the requested object is a the base class object > > Line 133 does not work since the requested object is a child class object > > How can I configure sqa to be able to get the whole child without having > later refreshes ? > > > > use the with_polymorphic() method of Query described at > http://docs.sqlalchemy.org/en/rel_0_7/orm/inheritance.html#basic-control-of-which-tables-are-queried. > 0.8 will have a more capable and flexible version of this function. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/KBo7kLs36jYJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.