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

Postgrest.Exceptions.PostgrestException: {"code":"42883","details":null,"hint":"No operator matches the given name and argument types. You might need to add explicit type casts.","message":"operator does not exist: text @> unknown"} Dotnet Supabase #140

Closed
joseadrianoemmanuel1999 opened this issue Jan 26, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@joseadrianoemmanuel1999
Copy link

joseadrianoemmanuel1999 commented Jan 26, 2024

Bug report

"code":"42883"

Describe the bug

I am trying to use this command in my project :

await _SupabaseClient
                      .From<Products>()
                      .Select("id,name,price,desc,brand_id:Brands(id,name),subcategory_id:Subcategories(id,name,category_id:Categories(id,name,gender)),Imgs(image),shop_id:users(id,fullname)")
                      .Filter(x=>x.brand_id.name.ToString(),Operator.Contains,new List<Object> {"Nike","Puma"}).Get();

When i try use have this is error:

Postgrest.Exceptions.PostgrestException: {"code":"42883","details":null,"hint":"No operator matches the given name and argument types. You might need to add explicit type casts.","message":"operator does not exist: text @> unknown"}

System information

  • OS: [ Windows]
  • Version of supabase-js: [e.g. 6.0.2]
  • Version of Dotnet : [7]
@joseadrianoemmanuel1999 joseadrianoemmanuel1999 added the bug Something isn't working label Jan 26, 2024
@acupofjose
Copy link
Member

acupofjose commented Jan 28, 2024

Hm. Seems like something is not being translated into the query correctly... it should be using the operators like specified here. (Notes for implementing a fix)

Off the top of my head, I wonder if ?tags=cs.{example, new} is being sent incorrectly as ?tags=cs.{"example", "new"}.

Could you try the In operator instead and see if that works?

@joseadrianoemmanuel1999
Copy link
Author

Thanks to respond me, Yes i try use operator In and nothing is working.

@acupofjose
Copy link
Member

I'm able to duplicate, but I'm not sure what the issue is with the CONTAINS operator. The request is being formed according to their documentation. I'm going to open an issue on the postgrest repo and see if they have an issue.

It looks like the functionality you're looking for is available using the IN operator though.

The following test case works (relative to the PostgrestTests part of the repo) as expected:

[TestMethod("filters: cs (list)")]
public async Task TestContainsFilterList()
{
    var client = new Client(BaseUrl);

    var filteredResponse = await client.Table<User>()
        .Filter(x => x.Username!, Operator.In, new List<string> { "dragarcia", "acupofjose" })
        .Get();

    filteredResponse.Models.ForEach(x => Assert.IsTrue(x.Username is "dragarcia" or "acupofjose"));
}

@acupofjose
Copy link
Member

@joseadrianoemmanuel1999 the answer given the issue:

The contains operator @> does not work for text types. It's used for arrays, json(b) and others. Are you trying to query all the users with username that belong to a list of candidates? If so you can use like(any).

So please use the IN or LIKE operator!

@joseadrianoemmanuel1999
Copy link
Author

It's worked but it's sad other command fails, But thanks for help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants