On Thu, May 04, 2006 at 11:43:21AM -0400, Michael Bayer wrote:
> I juts commited a tweak in 1387 to make this easier. your test
> program can do:
>
> ret = m.select("city_name = 'Rome'", from_obj=[cities], limit=10)
>
> or more correctly:
> ret = m.select("city.city_name = 'Rome' and
> city.city_id=users.city_id", from_obj=[cities], limit=10)
The second one works now, thanks!
> [the first one would give]
>
> SELECT users.city_id AS users_city_id, users.user_name AS
> users_user_name, city_e54b.city_id AS city_e54b_city_id,
> city_e54b.city_name AS city_e54b_city_name, city_e54b.country AS
> city_e54b_country, users.user_id AS users_user_id
> FROM (SELECT users.user_id AS users_user_id
> FROM users, city
> WHERE city_name = 'Rome'
> LIMIT 10 OFFSET 0) AS rowcount, users LEFT OUTER JOIN city AS
> city_e54b ON city_e54b.city_id = users.city_id
> WHERE rowcount.users_user_id = users.user_id
If I understand correctly this will just fail. The inner select will get
garbage since it misses NATURAL JOIN or USING
so the 'more correctly' is the real choice. In this case I insit on the
question posed today by Randall Smith on 'predefined relationships' since I
think I didn't really understand your answer.
What I'd like to do is to put all info on join in the mapper, then I'd just
pass whereclauses, why should I pass 'from_obj' to the select rather that to
the mapper. When writing about 'custom join' in 'advanced mapping' you
suggest to use primaryjoin and secondary join to 'circumvent' fk mechanism,
so that I'd think that mechanism should be up by default.
Really I think that if you create a join out of a mapper, the only way it's
reasonable to use it is as a join, so that a select as the first in the message
(no errors, just garbage result) should not be possible (or at east not
_easy_). It's just looking for troubles.
Ideally what I'd like to do is to pass some parameters to the relation
saying if I want an innner or outer join. We have 'join' and 'outerjoin'
constructor but I'm not sure if I can use them (and how) in mapper to be
sure they will be used all the times and if we need them at all in case we
have fk correctly set up.
Thanks again
sandro
*:-)
PS: it sort of embarasses me to ask you to solve _my_ problem... I just
hope (and think) this is a pretty general need ;-)
--
Sandro Dentella *:-)
e-mail: [EMAIL PROTECTED]
http://www.tksql.org TkSQL Home page - My GPL work
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users