-
Notifications
You must be signed in to change notification settings - Fork 223
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
#2114 repeating query in django view #2158
base: main
Are you sure you want to change the base?
Changes from 3 commits
d0a94bd
66c8991
eb673d4
d4df8e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -36,6 +36,7 @@ | |||||||||||||||
import uuid | ||||||||||||||||
from decimal import Decimal | ||||||||||||||||
|
||||||||||||||||
from django.db.models import QuerySet | ||||||||||||||||
from elasticapm.conf.constants import KEYWORD_MAX_LENGTH, LABEL_RE, LABEL_TYPES, LONG_FIELD_MAX_LENGTH | ||||||||||||||||
|
||||||||||||||||
PROTECTED_TYPES = (int, type(None), float, Decimal, datetime.datetime, datetime.date, datetime.time) | ||||||||||||||||
|
@@ -144,6 +145,9 @@ class value_type(list): | |||||||||||||||
ret = float(value) | ||||||||||||||||
elif isinstance(value, int): | ||||||||||||||||
ret = int(value) | ||||||||||||||||
elif isinstance(value, QuerySet): | ||||||||||||||||
value._result_cache = [] | ||||||||||||||||
ret = repr(value) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Instead of erasing the values everytime shouldn't we just do something is value._result_cache is None? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, there is a little less magic to your solution 👌 |
||||||||||||||||
elif value is not None: | ||||||||||||||||
try: | ||||||||||||||||
ret = transform(repr(value)) | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point i will change it 👌