1
from sqlobject import *
2
from sqlobject.tests.dbtest import *
4
########################################
6
########################################
8
class Distinct1(SQLObject):
11
class Distinct2(SQLObject):
12
other = ForeignKey('Distinct1')
17
result[int(ob.n)] = result.get(int(ob.n), 0)+1
21
setupClass([Distinct1, Distinct2])
22
obs = [Distinct1(n=i) for i in range(3)]
23
Distinct2(other=obs[0])
24
Distinct2(other=obs[0])
25
Distinct2(other=obs[1])
27
query = (Distinct2.q.otherID==Distinct1.q.id)
28
sel = Distinct1.select(query)
29
assert count(sel) == {0: 2, 1: 1}
30
sel = Distinct1.select(query, distinct=True)
31
assert count(sel) == {0: 1, 1:1}