Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Double many-to-many relation filter headache
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vlad K.  
View profile  
 More options Oct 2 2012, 6:28 am
From: "Vlad K." <v...@haronmedia.com>
Date: Tue, 02 Oct 2012 12:28:16 +0200
Local: Tues, Oct 2 2012 6:28 am
Subject: Re: [sqlalchemy] Double many-to-many relation filter headache
On 10/01/2012 04:48 PM, Michael Bayer wrote:

> If I understand correctly, this isn't accurate.  Your query needs the usage of query.join(), and this usage is not related to whether or not you supply a complete entity to select from.

I wasn't using explicit .join(), except an outerjoin on a one-to-one
relation with images table (which by default is lazyloaded). I thought
SQLA would figure it out itself based on foreign keys, as it usually
does. Maybe that's wrong, maybe I should be explicit, but so far it
worked (when entire instances of declarative_base were given to
session.query()).

I forgot to mention, and this could be the cause of perceived problems,
that I was listing columns of more than one model in the
session.query(). Maybe that confused it.

What happened was that the query returned a list of named tuples for
each of the rows returned by the database, while I was expecting only
one instance of the main model (see below).

> I'm not sure what "won't automatically process inner joins" means, does that mean, you get an error message, or you're forced to call .join() as opposed to some other system of joining two entites, or what.

I mean the cartesian cross-product in queries with many-to-many
relations. SQLA would "automatically" recognize the queried models and
construct the model instances and their relationships properly.

E.g. if I query for single model that has X related in a many-to-many
fashion, the query would return X number of rows, like with
.joinedload(), but SQLA would return only one instance of the model, and
its related property filled with a list of X instances of that model,
i.e it would automatically process the joins and create a relationship
tree in the session.

I hope I'm making sense here. :)

I guess I should make a minimal example case for this, and will do as
time permits.

--

.oO V Oo.

Work Hard,
Increase Production,
Prevent Accidents,
and
Be Happy!  ;)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.