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

Disable the {filter: {q: ""}} created by default from ReferenceInput #4036

Closed
multimeric opened this issue Nov 25, 2019 · 1 comment · Fixed by #4039
Closed

Disable the {filter: {q: ""}} created by default from ReferenceInput #4036

multimeric opened this issue Nov 25, 2019 · 1 comment · Fixed by #4039
Assignees
Labels

Comments

@multimeric
Copy link

multimeric commented Nov 25, 2019

Is your feature request related to a problem? Please describe.
By default, a <ReferenceInput> component generates a GET_LIST request, with the params set to {filter: {q: ""}}, aka an empty filter for the column q.

This is a strange behaviour, because backends may actually try to interpret this filter, even though it has no value. For example, flask-rest-jsonapi tries to filter by a column called q, which doesn't exist. Similarly, discussion in #2615 shows this problem in a different backend.

Describe the solution you'd like
By default, a <ReferenceInput> should not add any parameters to the GET_LIST request. Instead, users should be required to implement a filterToQuery function, where they can add their own filter if needed.

In terms of the actual code, I think the only thing we'd need to do is change the default prop value of filterToQuery to a no-op:

filterToQuery: searchText => ({ q: searchText }),

Describe alternatives you've considered
Currently this default behaviour can be disabled by adding a no-op filterToQuery, e.g.:

<ReferenceInput
    filterToQuery={() => {}}
>

I'd be happy to write a PR if this would be acceptable.

@fzaninotto
Copy link
Member

Thanks, reproduced and confirmed. I'll post a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants