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
Exception 'Exists' object has no attribute 'rhs' #156
Comments
Interesting. Are you on Cachalot 2.2.0, the latest? It seemed like a
problem post Django 2.2 and it should’ve been fixed... Will look into it if
it’s not the version issue.
…On Tue, Jun 23, 2020 at 4:18 AM John-Paul Stanford ***@***.***> wrote:
What happened?
We are running django-cachalot in production and keep getting exceptions
"'Exists' object has no attribute 'rhs'". This is captured in sentry, so we
can see some of the details.
It's comming from the following line in cachalot/utils.py:
rhs = child.rhs
Here are some of the details set at this point:
- child - django.db.models.expressions.Exists object
- child_class - django.db.models.expressions.Exists
- children -
[django.db.models.lookups.Exact,django.db.models.expressions.Exists]
- rhs - uuid.UUID
- rhs_class - uuid.UUID
What should've happened instead?
No exception
Steps to reproduce
Seems to happen on DB quieries that make use of
django.db.models.expressions.Exists.
Django==3.0.6
Postgres DB (12.x)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#156>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOLG4VVOUIRRWNY7OF5J3UTRYBQNHANCNFSM4OFNIFRQ>
.
|
Yes, we should be on the latest. I have the django-cachalot==2.2.0 in the requirements file. |
@shield007 Hm. #132 (that was merged in a different commit) was supposed to fix Django's extensions. I'll look into it. Do you mind posting traceback? It's fine if you don't; you may not need to. |
@Andrew-Chen-Wang Sure, here is the traceback we got, I've striped out the lins from our code base. But if thats a problem let me know. It's probally fine to include them. Just taking them out while they are not needed: AttributeError: 'Exists' object has no attribute 'rhs' removed application code File "django/views/generic/base.py", line 71, in view removed application code File "newrelic/hooks/framework_django.py", line 931, in wrapper removed application code File "django/db/models/query.py", line 276, in iter Also because we have this captured in sentry, I can access any of the local varibles anywhere though that backtrace stack. So let me know if you need them to help debuging. |
Also dobule checked the running version and it is indeed 2.2.0. /app # pip freeze | grep cachalot
django-cachalot==2.2.0 |
@shield007 Thanks for adding your traceback. I understand the problem. Please look out for cachalot 2.2.2. The problem WAS fixed, but I apparently didn't put it in cachalot 2.2.0. It's actually fixed in master branch. Sorry for the inconvenience. That patch for 2.2.2 should come out today. |
@shield007 I'm going to close this issue now since I just published version 2.2.2 which should come with the fix. Sorry for the inconvenience! Please reopen this if the issue persists. |
Thanks for looking into it. Will test 2.2.2 today. |
We still see problems with the 2.2.2 relase. Here is a stack we are getting:
|
Can this issue be reopened ? |
I see. Same problem. Perhaps, if we moved the subquery into the try block? @shield007 Do you mind posting a sample query? I'd like to get all subqueries fixed because it seems to be a recurring issue since Django 2.2. |
I've looked into this a bit, I know have some code to reproduce the problem from the django shell. From what I can see the main issue is that on line 117, |
I've now created a pull request, #157. This fixes it for me. Hopefully this helps with the issue. |
@shield007 Yes, but I didn't want #157 to invalidate Exists subqueries from working with cachalot. The deleted lines in your PR was there so that your subquery could work with cachalot in Django 2.2. I'd much rather find a solution to getting it to work than for it to not work. You can use #155 whenever someone gets around to working on disabling cachalot temporarily via a context manager. Hopefully soon from my end. |
* Combine child_class passing to minimize if's Co-authored-by: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com>
@shield007 I've merged your PR for version 2.3.0. If it's still not working, you can use the new context manager to disable cachalot. Please let me know if there are any problems. |
ping |
* Reverts #157 with proper fix. The initial problem was due to `django.db.models.expressions.Subquery` allowing both QuerySet and sql.Query to be used. * Fixes Django 3.2 test_subquery and test_invalidate_subquery testing by also checking the lhs
* Remove system check for Django version * Closes #175 * Bump version and amend CHANGELOG * Update with GitHub action CI * Update README with Python and Django versions * Limit Django version to 3.2, inclusively. * Add note on Django constraints to README * Bump minor version * Justified by dropping support for dependency versions * Drop support for Django 2.0-2.1, Python 3.5 * Change CI badge in README to GitHub actions * Add support for Pymemcache for Django 3.2+ * Add Django 3.2 to test matrix * Fix MySQL test_explain * Allow filebased delta leniency in tests * Allow Subquery in finding more Subqueries (Fixes #156) * Reverts #157 with proper fix. The initial problem was due to `django.db.models.expressions.Subquery` allowing both QuerySet and sql.Query to be used. * Fixes Django 3.2 test_subquery and test_invalidate_subquery testing by also checking the lhs * Fix Django 2.2 Subquery having no query attr * Fix filebased test time delta * Fix test_invalidate_having due to new inner_query * The new inner_query replaces subquery for Django 3.2 where subquery is now a boolean. That's why I initially used that TypeError in _get_tables_from_sql. inner_query looks to be a sql.Query * Add PyMemcacheCache to supported cache backends Co-authored-by: Dominik George <nik@naturalnet.de>
What happened?
We are running django-cachalot in production and keep getting exceptions "'Exists' object has no attribute 'rhs'". This is captured in sentry, so we can see some of the details.
It's comming from the following line in cachalot/utils.py:
rhs = child.rhs
Here are some of the details set at this point:
What should've happened instead?
No exception
Steps to reproduce
Seems to happen on DB quieries that make use of django.db.models.expressions.Exists.
Django==3.0.6
Postgres DB (12.x)
The text was updated successfully, but these errors were encountered: