nestjsx / crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
4.01k stars 526 forks source link

Array text fields : QueryFailedError when using CondOperator.CONTAINS #793

Open BenStirrup opened 2 years ago

BenStirrup commented 2 years ago

Bug Report

Current behavior

There is an error at the level of the ORM : QueryFailedError: operator does not exist: text[] ~~ unknown.

Input Code

// DB schema field
@Column('text', { array: true, default: [UserRole.EMPLOYEE] })
roles: UserRole[]

// Contraint type in filter / or
{ field: 'roles', operator: CondOperator.CONTAINS, value: UserRole.EMPLOYER }

Expected behavior

We should be able to filter on array fields.

Possible Solution

Modify the SQL generated when the field is an array.

Environment