[英]PeeWee: select() always repeats first two rows
ids = "1,2,3,4"
idlist = [int(i) for i in ids.split(',')] # [4, 1, 2, 3]
jobs = Job.select().join(User).distinct().where(Job.id << idlist).dicts()
if (jobs.count()):
for i, job in enumerate(jobs):
print str(i) + " : " + str(job['id'])
returns : 返回:
0 : 1
1 : 2
2 : 1
3 : 2
4 : 3
5 : 4
expected: 预期:
0 : 1
1 : 2
2 : 3
3 : 4
What is causing this? 是什么原因造成的?
jobs.count()
returns 4. I even added distinct() but seems like none of it is making an impact, really confusing. jobs.count()
返回4。我什至添加了distinct(),但似乎没有一个产生影响,确实令人困惑。
With sqlite if you are saving inside the loop, this may be the issue: 使用sqlite如果您要保存在循环中,则可能是以下问题:
https://github.com/coleifer/peewee/issues/12#issuecomment-5614404 https://github.com/coleifer/peewee/issues/12#issuecomment-5614404
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.