Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django-cacheops breaks django-polymorphic #222

Closed
mjnaderi opened this issue Dec 8, 2016 · 2 comments
Closed

django-cacheops breaks django-polymorphic #222

mjnaderi opened this issue Dec 8, 2016 · 2 comments

Comments

@mjnaderi
Copy link
Contributor

mjnaderi commented Dec 8, 2016

Hi. I installed latest versions of django-cacheops and django-polymorphic:

  • python==3.5.2
  • django==1.10.3
  • django-cacheops==3.1.1
  • django-polymorphic==1.0.2

With these versions, django-polymorphic does not work correctly. When I downgrade django-cacheops to 3.1, the problem still exists, and when I downgrade django-cacheops to 3.0.1, the problem goes away. Something in CacheOps 3.1 has broken django-polymorphic.

This is the problem:

Suppose we have following models.

class A(PolymorphicModel):
    pass


class B(A):
    pass


class Z(models.Model):
    a = models.ForeignKey(A)

Both A, and B are cached using cacheops, using these settings in settings.py:

CACHEOPS = {
    'myapp.a': {'ops': 'all', 'timeout': 60 * 15},
    'myapp.b': {'ops': 'all', 'timeout': 60 * 15},
}

I run following commands in django shell:

>>> from myapp.models import A
>>> from myapp.models import B
>>> from myapp.models import Z
>>> b=B.objects.create()
>>> z = Z.objects.create(a=b)
>>> z2 = Z.objects.get(id=z.id)
>>> type(z.a)
<class 'myapp.models.B'>
>>> type(z2.a)
<class 'myapp.models.A'>

As you see, type of z2.a is "A", bit it should be "B". With cacheops 3.0.1, this is the result:

>>> type(z.a)
<class 'myapp.models.B'>
>>> type(z2.a)
<class 'myapp.models.B'>
@Suor
Copy link
Owner

Suor commented Dec 8, 2016

Have no idea why this is hapening. I can look into it if you provide a test.

But you should be aware that cacheops doesn't support multi-table inheritance in a sense that invalidation could be incomplete with it - #31.

@mjnaderi
Copy link
Contributor Author

mjnaderi commented Dec 9, 2016

I wrote a failing test for this issue: #223

@Suor Suor closed this as completed in c5fb0dc Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants