下面的前三个查询返回正确的数字,而最后一个查询返回错误的数字。它应该返回153,而不是返回8193。我不知道那个号码是从哪儿来的。在
正确地迭代查询返回153条记录。在
>>> Project.select().where(Project.number.between('2012-01', '2012-02')).count()
75
>>> Project.select().where(Project.number.between('2012-02', '2012-03')).count()
78
>>> Project.select().where(Project.number.between('2012-01', '2012-03')).count()
153
>>> (Project.select().where(Project.number.between('2012-01', '2012-02')) |
Project.select().where(Project.number.between('2012-01', '2012-03'))).count()
8193
编辑
这是一个函数,它从一个空数据库开始重现问题。在
^{pr2}$这是它的输出。它表明迭代正确返回4项,但计数错误:
<class 'DocFinder.DocFinder.DocFinder.test.<locals>.Test'> SELECT t2."id", t2."num" FROM "test" AS t2 WHERE (t2."num" > ?) UNION SELECT t3."id", t3."num" FROM "test" AS t3 WHERE (t3."num" > ?) [6, 7]
Count = 7
7
8
9
10
请尝试改用
.wrapped_count()
。在相关问题 更多 >
编程相关推荐