On Sep 3, 2008, at 3:26 PM, mg wrote:
>
> here is my code:
> c_table = Table('campaign', metadata,
> Column('id', Integer, primary_key=True),
> Column('content', Unicode(200)),
> )
>
> m_table = Table('mailings', metadata,
> Column('id', Integer, primary_key=True),
> Column('campaign_id',Integer, ForeignKey('campaign.id')),
> Column('date', DateTime),
> )
>
> class Mailing(object):
> pass
> class Campaign(object):
> pass
>
> mapper(Campaign, c_table)
> mapper(Mailing, m_table,
> properties={'published_campaign':relation(Campaign, uselist=False) })
>
> my question is this, when I do the following:
> mailing =
> session.query(Mailing).options(eagerload('published_campaign')).get(1)
> the resulting query does an outer join. How can I have it do a regular
> join?
It depends on what you're trying to accomplish here.
1. if you just want to join to the other table, its
session.query(Mailing).join(Mailing.published_campaign) , but this
will not affect the "published_campaign" colllection; thats held as a
separate join.
2. if you're just trying to optimize the eager load,
sess
.query
(Mailing
).join
(Mailing
.published_campaign).options(contains_eager('published_campaign'))
3. otherwise eagerload always uses an outer join; a possible future
improvement would be that it uses a join if the foreign key column is
not nullable, but thats not the case now.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---