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

Additional Support for Filtering on Varchar Arrays via Requests #687

Open
dylanflint07 opened this issue Mar 31, 2021 · 0 comments · May be fixed by #754
Open

Additional Support for Filtering on Varchar Arrays via Requests #687

dylanflint07 opened this issue Mar 31, 2021 · 0 comments · May be fixed by #754

Comments

@dylanflint07
Copy link

Suppose I want to filter entities in nestjs which contains a field with the following:

  @IsArray()
  @Column('varchar')
  public languages?: String[];

which is defined by a migration as such:

{
    name: 'languages',
    type: 'varchar',
    isArray: true,
    isNullable: true,
},

Using this I'm attempting to acquire entities that contain a list of languages. However, I've run into issues when attempting to filter the entities based on this field. I'm attempting to return entities which contain any language from a list of provided languages. The filters don't seem to support this.

Ex.


filter=languages||in||{Spanish},{English},{French},{Mandarin}

This will return results whose language array ONLY contains one of those fields. Entities that contain multiple languages in this list (Example: French,Spanish) will not be returned.

A solution to this would be to send something akin to this:

filter=languages||in||{Spanish},{English}&or=languages||eq||{English,Spanish}&or=languages||eq||{Spanish,English}

But I would have to provide all possible combinations for this in order to get this to work at all. Which does not seem like a good solution at all.

Is there a way to just do something with cont, or would it be possible to implement that functionality in a different manner? Currently if you attempt something like

filter=languages||cont||{Mandarin}

this will result in the following error

{
    "statusCode": 500,
    "message": "operator does not exist: character varying[] ~~ unknown"
}
@emmanuel emmanuel linked a pull request Dec 7, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant