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

Support in query filter #173

Open
enzo-crance-statnett opened this issue Oct 18, 2024 · 1 comment
Open

Support in query filter #173

enzo-crance-statnett opened this issue Oct 18, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@enzo-crance-statnett
Copy link

Hello.

On one of our React-Admin pages, we have to filter a list on an enum field, keeping only rows whose value for this field is in a subset selected by the user in a CheckboxGroupInput component :

<CheckboxGroupInput
  label="Enumfield"
  source="enumfield@in"
  choices={[
    { id: "a", name: "A" },
    { id: "b", name: "B" },
    { id: "c", name: "C" },
  ]}
/>

The source property here is expressed in the syntax expected by this library, so the in query filter type is correctly translated into enumfield=in. in the query to be sent to the server.

However, the filter value coming from the input component is an array of strings (e.g., ["a", "c"] if only boxes A and C are checked), and it looks like there is no support for that in this library. Indeed, what we get in the final URL filter is enumfield=in.a,c whereas it should be enumfield=in.(a,c) according to the PostgREST syntax. Could you please confirm that ?

If you are open to contributions, we could propose a fix by adding a case for the in query filter type in the parseFilters function in urlBuilder.ts, if that makes sense.

Thanks for your help.

@scheiblr
Copy link
Collaborator

scheiblr commented Oct 31, 2024

Hey @enzo-crance-statnett. Excuse my late reaction, I was currently very busy. You could have a look at the test cases, which might give you some insight, which functionality should already work and is implemented in the current state. In my opinion that would also be the fist step, i.e. creating test cases for you idea. Genrally, I like the approach of implementing the in for the filter. And I am very happy about contributions - thank you for the offer. Feel free to extend the library. That is the idea of making tools as such OS :)

@scheiblr scheiblr added the enhancement New feature or request label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants