문제

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.

도움이 되었습니까?

해결책

With sqlite if you are saving inside the loop, this may be the issue:

https://github.com/coleifer/peewee/issues/12#issuecomment-5614404

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top