nestjsx / crud

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

Postgres string filters use LIKE instead of ILIKE #741

Closed yleflour closed 2 years ago

yleflour commented 2 years ago

I was trying to use a search filter using the TypeOrmCrudService and a postgres database.

While successful I noticed that the filter was case sensitive. By going through the code, I noticed that the service uses LIKE or ILIKE depending on the database type.

But when debugging the constructor, I noticed that this.repo.metadata.connection.options.type isn't available, so my queries use LIKE instead of ILIKE

The current workaround is to set this.dbName = "postgres" manually in the constructor.

My hypothesis is that the this.repo.metadata.connection.options.type field was removed in recent versions of TypeORM but I haven't had the time to check.

yleflour commented 2 years ago

I used the wrong operator ($cont instead of $contL)