home / django_tickets / tickets

tickets: 10060

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
10060 2009-01-18 06:44:38 2021-10-18 20:42:34 2022-03-06 03:46:21.619637 Accepted new Database layer (models, ORM) Bug Normal dev   Multiple table annotation failure Annotating across multiple tables results in wrong answers. i.e. {{{ In [110]: total = Branch.objects.all().annotate(total=Sum('center__client__loan__amount')) In [111]: total[0].total Out[111]: 3433000 In [112]: repaid = Branch.objects.all().annotate(repaid=Sum('center__client__loan__payment_schedule__payments__principal')) In [113]: repaid[0].repaid Out[113]: 1976320.0 In [114]: both = Branch.objects.all().annotate(total=Sum('center__client__loan__amount'),repaid=Sum('center__client__loan__payment_schedule__payments__principal')) In [115]: both[0].repaid Out[115]: 1976320.0 In [116]: both[0].total Out[116]: 98816000 ^^^^^^^^^^^ }}} Compare the output of total in 116 vs. 111 (the correct answer).   svsharma@intellecap.net   0 0 0 0 0 0
Powered by Datasette · Queries took 1.254ms