Hi,
I'm trying to do a simple distinct query in a database but something
weird i couldn't figure out happens.
The distinct=True doesn't seem to produce distinct results with
In [23]: useful_movies=movies_with_titles&with_poster
In [24]: page=0
In [25]: a = db(use).select(db.movies.ALL, orderby=~(db.movies.year),
distinct=True, limitby=(page*ITEMS_PER_PAGE,page*ITEMS_PER_PAGE+ITEMS_PER_PAGE))
useful_movies use_janrain
In [25]: a = db(useful_movies).select(db.movies.ALL, orderby=~(db.movies.year),
distinct=True, limitby=(page*ITEMS_PER_PAGE,page*ITEMS_PER_PAGE+ITEMS_PER_PAGE))
In [26]: for m in a:
print m.id
....:
129721
154777
27062
18867
54900
5417
47040
149757
54872
82138
50718
215
49336
33866
88653
In [27]: page=1
In [28]: a = db(useful_movies).select(db.movies.ALL, orderby=~(db.movies.year),
distinct=True, limitby=(page*ITEMS_PER_PAGE,page*ITEMS_PER_PAGE+ITEMS_PER_PAGE))
In [29]: for m in a:
print m.id
....:
129721
215
54900
27062
154777
33866
149718
54872
149757
120978
18867
49336
47040
560
48547
In [30]: useful_movies
Out[30]: <Query ((NOT (movies.title IS NULL)) AND (NOT (movies.poster =
'images/unknown_poster.jpg')))>
also without distinct I have multiple occurrences of the same ids:
In [33]: a = db(useful_movies).select(db.movies.ALL, orderby=~(db.movies.year),
limitby=(page*ITEMS_PER_PAGE,page*ITEMS_PER_PAGE+ITEMS_PER_PAGE))
In [34]: for m in a:
print m.id
....:
37544
27062
48547
22928
4737
27039
560
54872
47040
50730
3665
26883
50718
29694
29652
In [35]: page=1
In [36]: a = db(useful_movies).select(db.movies.ALL, orderby=~(db.movies.year),
limitby=(page*ITEMS_PER_PAGE,page*ITEMS_PER_PAGE+ITEMS_PER_PAGE))
In [37]: for m in a:
print m.id
....:
54872
47040
47365
3665
26883
50718
50730
22928
27039
37544
46746
29652
29694
73069
54900
In [38]:
Any clue of what's going on?
Thank you. any help would be appreciated.
--