-
Notifications
You must be signed in to change notification settings - Fork 130
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
Support nested queries for ComplexFilterBackend #312
Comments
Hi @gatensj - glad to hear someone is using the complex ops backend! Individual groups are your traditional query strings, so Your second attempt fails because nested groups aren't supported. Implementing a backend that supports That all said, in this specific case it looks like you want to match against multiple subscriber codes. You could get away with a CSV-based
Although, you don't really need the complex backend for the query since it's equivalent to
It might be good to update the documentation clarifying that individual groups match traditional query stings, and that each query string is processed by an individual filterset. |
Hey gang. I'm going to take a stab at this problem. Originally I was looking at parsing the string using the pyparsing package. If that proves problematic, I might end up parsing the string with the sqlparse package. Anyway here’s a link to my fork - I’ll be pushing every night. Feel free to follow along. Please let me know if you have any questions and I'll respond accordingly. Thanks. Take care. |
Hey, sorry if this is a little off topic but I am looking at using the complex backend and I am a little confused. So do i need to write the code to parse the query string and encode it or is there a library you are using to do that? Also where do I do that at? Is there some example code I can look at? |
Hi @patrickcash - I moved your question to #316.
I unfortunately don't have the bandwidth to implement this. The current implementation was only possible because I assumed certain limitations (specifically, no nesting 😄). That said, I'd be happy to help review any PR on this. Besides parsing the query, the most difficult part will be to properly nest any validation errors. |
Supported in this PR: |
Hey everybody. I’m using Django-rest-framework-filters for a project and it is great. Reason for message, is I’m running into issue with complex operations. Specifically I’m having trouble with grouping logic.
This is the unencoded filter:
(vendor_code=clrvt) & (subscriber_code=tamu | subscriber_code=princeton)
Which encodes to
%28vendor_code%3Dclrvt%29+%26+%28subscriber_code%3Dtamu+%7C+subscriber_code%3Dprinceton%29
*** When I try to view this in the Browsable API, it returns a count however the results are an empty list, because the generated SQL can not parse the nested conditional (
"wrdsrpts_rep_usage"."usage"."subscriber_code" = 'tamu | subscriber_code=princeton'
):I tried adding containing parentheses. This is the unencoded filter:
((vendor_code=clrvt) & (subscriber_code=tamu | subscriber_code=princeton))
Which encodes to
%28%28vendor_code%3Dclrvt%29+%26+%28subscriber_code%3Dtamu+%7C+subscriber_code%3Dprinceton%29%29
*** When I try to view this in the Browsable API, It returns a status 400 for a bad request. The message is
Ending querystring must not have trailing characters. Matched: ')'.
It’s possible that I may have misunderstood the proper syntax. If this is the case, please let me and I’ll be happy to issue a PR to update the documentation. Any and all help on this front will greatly be appreciated. Thanks for your help. Take care and talk to you soon.
The text was updated successfully, but these errors were encountered: