Hi I'm trying do make a query:

I want to get all the movies that have ratings on my database.
db.ratings is a many to many relationship with db.users and db.movies

I did:

In [7]: db(db.ratings.imovie.belongs(db.movies))._select(db.movies.ALL)
Out[7]: 'SELECT  movies.id, movies.imdb_id FROM ratings, movies WHERE
(ratings.imovie IN (movies.id,movies.imdb_id));'

Which is good but takes too much time. In particular i wanted to
restrict the IN clause to movies.id only so i did:

In [8]: db(db.ratings.imovie.belongs(db.movies.id))._select(db.movies.ALL)
Out[8]: 'SELECT  movies.id, movies.imdb_id FROM ratings, movies WHERE
(1=0);'

It replaced all the IN with a 1=0 clause. Very odd.

Is it a bug or am I doing something wrong?


-- 
Vincenzo Ampolo
http://vincenzo-ampolo.net
http://goshawknest.wordpress.com

-- 



Reply via email to