nestjsx / crud

NestJs CRUD for RESTful APIs

Home Page:https://github.com/nestjsx/crud/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array text fields : QueryFailedError when using CondOperator.CONTAINS

BenStirrup opened this issue · comments

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

  • nest crud : 5.0.0-alpha.3
  • typeorm: 0.2.45
  • Node version: 16.13.2
  • Database: Postgres