SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.21k stars 662 forks source link

Cannot filter by uuid id: operator does not exist: uuid ~~* unknown #932

Closed Dima-Kevanishvili closed 2 years ago

Dima-Kevanishvili commented 3 years ago

Describe the bug Trying to filter a resource by it's primary key(id) which has type of uuid. When entering a full uuid in filter input and pressing apply, I get an error message in console: SequelizeDatabaseError: operator does not exist: uuid ~~* unknown

Installed libraries and their versions

To Reproduce Steps to reproduce the behavior:

  1. Go to a resource with uuid type primary key
  2. Try to filter the resource with said uuid primary key
  3. get the error

Expected behavior I expect for the filtering to work correctly and give me the needed object

Additional context Suspecting that this happens because the generate query has ILIKE operator in where clause for uuid WHERE ("TABLE_NAME"."id" ILIKE '%3ad54072-c394-4020-b47e-c72dd29147a5%')

dziraf commented 2 years ago

This should be a matter of extending the if on this line: https://github.com/SoftwareBrothers/adminjs-sequelizejs/blob/master/src/utils/convert-filter.ts#L18

      if (property.sequelizePath.values) {

to

      if (property.sequelizePath.values || property.isId()) {

and moving ...memo above [property.name()]. You can see if it worked by editing node_modules/@adminjs/sequelize/lib/utils/convert-filter.js.

Can you open an issue in adminjs-sequelize repository? https://github.com/SoftwareBrothers/adminjs-sequelizejs/issues I'll close this one afterwards.

I'll also try to include a fix for this soon but I don't have a Sequelize+uuid project going at the moment so testing might take longer than actually fixing this

Dima-Kevanishvili commented 2 years ago

Done

helsonxiao commented 2 years ago

Any updates? Same error in TypeORM here :)

slidenerd commented 1 year ago

It is still not resolved completely. I have updated the issue mentioned above