select * in join

28 views
Skip to first unread message

Erik Wolf

unread,
Sep 7, 2014, 3:01:33 AM9/7/14
to pytho...@googlegroups.com
Hello, I really appreciate your work and enjoy working with your library. But I run into problems using the join-operations.

using your example i want the following result:

('SELECT "a".*, "b"."group" FROM "user" AS "a" INNER JOIN "user_group" AS "b" ON ("b"."user" = "a"."id")', ())

but this is not working:

>>> join = user.join(Table('user_group'))
>>> join.condition = join.right.user == user.id
>>> select = join.select(user, join.right.group)
>>> tuple(select)

Looking forward for your help. Best regards

Cédric Krier

unread,
Sep 7, 2014, 3:36:36 AM9/7/14
to pytho...@googlegroups.com
You can not select a table, it must always be an expression (a column).
Indeed in the example, the trick is that if you don't specify any
column, python-sql uses *.
So for your example, you have to use a Column named "*".

>>> select = join.select(getattr(user, '*'), join.right.group)

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
Reply all
Reply to author
Forward
0 new messages