marmelab / ra-supabase

Supabase adapter for react-admin, the frontend framework for building admin applications on top of REST/GraphQL services.
MIT License
156 stars 27 forks source link

AutocompleteInput inside of ReferenceInput #35

Closed kassim3 closed 1 year ago

kassim3 commented 1 year ago

I'm currently having issues trying to get the autocomplete to search properly. I've got a currency table and a country table. The country table has a field called "currency_id".

This is what i currently have:

      <ReferenceInput source="currency_id" reference="currency">
        <AutocompleteInput name="currency_id" optionText={"code"} />
      </ReferenceInput>

The issue is the request being sent to supabase is the following: http://localhost:54321/rest/v1/currency?order=id.desc&offset=0&limit=25&q=eq.ddf

This is a causing a 400 error from supabase stating that following: {"code":"42703","details":null,"hint":null,"message":"column currency.q does not exist"}

I'm probably being dumb but am i forgetting to do something? Let me know if you need more information

fzaninotto commented 1 year ago

Hi, and thanks for your question. As explained in the react-admin contributing guide, we use the GitHub issues for bugs and feature requests only.

For support question ("How To", usage advice, or troubleshooting your own code), you have three options:

So I'm closing this issue, and inviting you to ask your question in one of the support channels above.

slax57 commented 1 year ago

@kassim3 You probably need to customize the filterToQuery prop of the AutocompleteInput to match a filter that PostgREST will understand.

In the Demo App of this repo, we used full-text search (fts) features of supabase to perform the filtering.

kassim3 commented 1 year ago

@kassim3 You probably need to customize the filterToQuery prop of the AutocompleteInput to match a filter that PostgREST will understand.

In the Demo App of this repo, we used full-text search (fts) features of supabase to perform the filtering.

Thanks i already figured it out. Like you said i had to filterToQuery but I had to do the following which works now:

      <ReferenceInput source="currency_id" reference="currency">
        <AutocompleteInput
          name="currency_id"
          optionText={"code"}
          filterToQuery={(q) => ({ "code@ilike": q })}
        />
      </ReferenceInput>