Thank you,
In the last suggestion:
@property
def users_and_orders(self):
return self.users + self.orders
or to simulate a polymorphic union, do
object_session(self).query(....).union(object_session(self).query(....))
etc.
Do you have any suggestions to make the result have an append/remove
method which persists to the database?
Perhaps with a descriptor or custom collection type?
Cheers, Lars
On Apr 15, 6:49 am, Michael Bayer <[email protected]> wrote:
> On Apr 13, 2011, at 5:52 AM, Lars wrote:
>
> > Hi Michael,
>
> > I am trying to figure out the two suggestions you did, and not getting
> > very far. Some basic questions:
>
> > - if A, B, C are mapped classes, can you do A.join(B, A.id ==
> > B.id).join(C, B.id == C.id).join( .... ?
>
> usually if you want to use join() you'd deal with tables, like
> table_a.join(table_b, ...).join(...). though the orm.join() function will
> receive classes directly, its
> inhttp://www.sqlalchemy.org/docs/orm/tutorial.html#querying-with-joins
>
> > - Would using join in such a way make access to mapped attributes in
> > one of the joined tables excessively slow?
>
> joins are slower than straight single table selects especially in MySQL, if
> thats the question
>
> > - What is the difference between using association_proxy and
> > relationship(... secondary = .., ..., secondaryjoin = ...)?
>
> three concepts. one is
> many-to-many:http://www.sqlalchemy.org/docs/orm/relationships.html#many-to-many next
> is the association pattern, a many to many where extra data is linked with
> each
> association:http://www.sqlalchemy.org/docs/orm/relationships.html#association-object next
> is association proxy, when you've worked with an association for awhile and
> are tired of saying parent.association.child and want to just skip the
> ".association" part in the usual case
>
> > - in the example in poly_assoc_generic.py, is there a way to define an
> > attribute on address that returns a list with both "orders" and
> > "users" with that address (and be able to append that list) ?
>
> these collections load from entirely different tables. Usually you'd need to
> do it manually:
>
> @property
> def users_and_orders(self):
> return self.users + self.orders
>
> or to simulate a polymorphic union, do
> object_session(self).query(....).union(object_session(self).query(....)) etc.
--
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.