#10197 closed (fixed)
Foriegn Key breaks pickling of QuerySet
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Cache system) | Version: | dev |
Severity: | Keywords: | pickle, queryset, annotate | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm using the latest version from svn (as of 1-4-09) and python2.5. I'm trying to pickle a QuerySet that is using annotate and I'm getting the following error:
raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle function objects
Here is what I'm trying to do:
(ProductChannel has OneToMany relationship with ProductChannelImage)
pc = ProductChannel.objects.filter(supplier=supplier) pc = pc.filter(status='new') pc = pc.annotate(num_images=Count('productchannelimage')) ... request.session['pc_qs'] = dumps(pc.query)
Before I added the annotation to the query it was pickling just fine.
Attachments (1)
Change History (12)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 16 years ago
milestone: | → 1.1 beta |
---|
comment:4 by , 16 years ago
milestone: | 1.1 beta → 1.1 |
---|
This is just an ordinary bug, not a feature. I think it can miss the 1.1 beta.
comment:5 by , 16 years ago
comment:6 by , 16 years ago
Sorry I am new at this. How do I subscribe to updates to this bug? Or will it do it automatically by me commenting?
comment:7 by , 16 years ago
The issue here is the storage of the foreign key on the Aggregation object, which is created here: http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/related.py#L86 (line 90).
comment:8 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:9 by , 15 years ago
Component: | Database layer (models, ORM) → Cache system |
---|---|
milestone: | 1.1 → 1.2 |
Needs tests: | set |
Resolution: | fixed |
Status: | closed → reopened |
Summary: | Annotate breaks pickling of QuerySet → Foriegn Key breaks pickling of QuerySet |
Triage Stage: | Accepted → Unreviewed |
I'm having problems pickling Querysets to cache with memcached. As soon as a relationship is followed we get:
Exception Type: TypeError
Exception Value: can't pickle function objects
This is from a simple query like:
cars = Car.objects.filter(advertcarisnull=False)
Have tried on 1.2 beta and numerous suggested SVN checkouts, all yield the same result.
Some other cache backend options are okay.
comment:10 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Please don't reopen tickets that were closed with a patch. You may be seeing a *similar* problem, but I can guarantee it's not the *same* problem, because the patch that was committed has a regression test that isn't failing.
I'm going to guess you're actually looking for #12924. If that ticket doesn't describe your problem, please open a new ticket with a complete set of reproduction instructions.
Problem verified, although I'm not entirely certain which function is causing the problem here.