[sqlalchemy] auto-load ForeignKey references?

2007-05-10 Thread Max Ischenko
Hi, If I have two tables related via foreign key how can I tell SA that accessing foreign key should fetch related object automatically? By default it simply gives me the FK as integer which is not what I want. Here are my mappers: wp_users_tbl = Table('wp_users', meta, autoload=True)

[sqlalchemy] Re: auto-load ForeignKey references?

2007-05-10 Thread Max Ischenko
Hello, On May 10, 4:38 pm, King Simon-NFHD78 [EMAIL PROTECTED] wrote: You're halfway there with your 'posts' relation. I think if you pass backref='author' in your relation, then WordpressPost objects will get an 'author' property which points back to the WordpressUser. Nope, it doesn't

[sqlalchemy] Re: auto-load ForeignKey references?

2007-05-10 Thread King Simon-NFHD78
Max Ischenko wrote: On May 10, 4:38 pm, King Simon-NFHD78 [EMAIL PROTECTED] wrote: You're halfway there with your 'posts' relation. I think if you pass backref='author' in your relation, then WordpressPost objects will get an 'author' property which points back to the WordpressUser.

[sqlalchemy] Re: auto-load ForeignKey references?

2007-05-10 Thread Max Ischenko
Hi, On 5/10/07, King Simon-NFHD78 [EMAIL PROTECTED] wrote: Nope, it doesn't work. At least, I can't get it to work. If I use backref='author' new attribute 'author' appears but equals None even though the author_id is something like 123. You're not getting caught by this, are you:

[sqlalchemy] Maybe possibly a mapper bug

2007-05-10 Thread Chris Perkins
This behavior stumped me for quite a while. At the bottom of the code, there are two ways of adding a property to a mapper. One of them works, and the other seems to me like it should probably work, but it doesn't. Is this a bug? from sqlalchemy import *

[sqlalchemy] Re: Viewing SQL of literals....

2007-05-10 Thread Michael Bayer
On May 10, 2007, at 1:07 PM, m h wrote: On 5/9/07, Michael Bayer [EMAIL PROTECTED] wrote: currently: statement.compile().construct_params() Thanks for the response. construct_params takes a params argument. Where do I find that? (the statement.compile() instance has a parameters

[sqlalchemy] Re: Maybe possibly a mapper bug

2007-05-10 Thread Michael Bayer
On May 10, 2007, at 12:05 PM, Chris Perkins wrote: if 0: # This works fine: pjoin = (T1_select.c.id==T2_select.c.parent_id) (T1_select.c.ver==T2_select.c.parent_ver) fks = [T1_select.c.id, T1_select.c.ver] else: # But this does not: pjoin =

[sqlalchemy] Re: Viewing SQL with Data Mapper

2007-05-10 Thread Michael Bayer
On May 10, 2007, at 5:21 PM, m h wrote: I'm playing around with doing queries with the data mapper and am wondering how to view the SQL generated for them. (Since there is no intermediate query or select instance, I'm at a loss). thanks, matt typically using echoing/logging. if you