#36707: Prefetch related query throwing "Expression tree is too large" error 
after
updating to Django 5.2 when using sqlite3 DB
-------------------------------------+-------------------------------------
     Reporter:  Alexandru Chirila    |                    Owner:  (none)
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  5.2
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |  worksforme
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

 * resolution:  duplicate => worksforme

Comment:

 I saw that you mentioned suspecting a regression, but you haven't provided
 information to reproduce. If you could git bisect that would help advance
 the triage.

 I put together a test, and it works for me. Could you provide your models?

 {{{#!py
 from django.contrib.auth.models import *


 def run():
     perm = Permission.objects.first()
     group = Group.objects.create(name="New Group")
     group.permissions.add(perm)
     users = [User(pk=i, username=str(i)) for i in range(22321)]
     users = User.objects.bulk_create(users, batch_size=5000)
     group.user_set.add(*users)
     print(User.objects.prefetch_related("groups__permissions"))
 }}}
 {{{#!py
 In [3]: run()
 <QuerySet [<User: 0>, <User: 1>, <User: 2>, <User: 3>, <User: 4>, <User:
 5>, <User: 6>, <User: 7>, <User: 8>, <User: 9>, <User: 10>, <User: 11>,
 <User: 12>, <User: 13>, <User: 14>, <User: 15>, <User: 16>, <User: 17>,
 <User: 18>, <User: 19>, '...(remaining elements truncated)...']>
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36707#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019a4f90544e-628ed348-9d08-40b3-b779-386ab98a6ccc-000000%40eu-central-1.amazonses.com.

Reply via email to