Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make bool values lowercase in solr query url - fixes #401 #435

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

Open
ch2ohch2oh wants to merge 3 commits into django-haystack:master
base: master
Choose a base branch
Loading
from ch2ohch2oh:lowercase-bool-in-solr-query

Conversation

@ch2ohch2oh
Copy link
Contributor

@ch2ohch2oh ch2ohch2oh commented Oct 14, 2023

Minor changes as titled. Also added a small util function to look up nested json objects.

@ch2ohch2oh ch2ohch2oh marked this pull request as draft October 14, 2023 17:45
@ch2ohch2oh ch2ohch2oh marked this pull request as ready for review October 14, 2023 17:56
result = result._next_page_query and result._next_page_query()


def get_nested(obj, keys, default=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is only used by a debug logging call, and it could be replaced by a standard dictionary get-with-default call there.

path_handler = handler
if self.use_qt_param:
path_handler = "select"
query_vars.append("qt=%s" % safe_urlencode(handler, True))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be unrelated to the proposed change.

# cover both cases: there is no response key or value is None
(decoded.get("response", {}) or {}).get("numFound", 0),
)
if decoded.get("grouped"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would defer support for grouped responses to a larger task which would provide more help for them - just changing a log message doesn't seem to add much value.

)

# Boolean options for Solr should be in lowercase.
self.assertTrue("True" not in safe_urlencode({"group": True}))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would pass a bug which encoded it as group=None or group="false".

Suggested change
self.assertTrue("True"notin safe_urlencode({"group": True}))
self.assertEqual("group=true", safe_urlencode({"group": True}))

which can't fail down to ascii.
"""
if IS_PY3:
for key, val in params.items():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, pysolr has avoided doing type coercion to avoid needing to know what type(s) Solr supports for a given field (e.g. a parameter like group is documented as accepting true but will also accept on or yes but not 1 or True) but I think this is relatively safe because Solr doesn't accept that value natively so the only case where this could cause a problem is if someone was passing a Solr string which they for some reason wanted to have processed literally — for example, if I had a Python app which used a Solr StringField for something and expected the literal value True or False because that field type isn't case-insensitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@acdha acdha acdha left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /