loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.93k stars 1.06k forks source link

[@loopback/sequelize] Attempting to use `options` in a `where` filter leads to "There is no equivalent operator" exception #9690

Open KalleV opened 1 year ago

KalleV commented 1 year ago

Describe the bug

This section of the code throws an exception if the "where" filter includes an "options" key: https://github.com/loopbackio/loopback-next/blob/96b9a56788937f081e61f1d48dc080c7233d394c/extensions/sequelize/src/sequelize/sequelize.repository.base.ts#L604

Example filter that will throw an exception:

where: {
   name: {
     like: '%abcdefg%',
     options: 'i'
   }
}

References:

Logs

No response

Additional information

No response

Reproduction

N/A

shubhamp-sf commented 1 year ago

@loopback/sequelize is meant to be used with SQL dialects, this option being only supported by LoopBack in its memory and MongoDB connectors is not expected to work correctly.

Screenshot 2023-06-25 at 12 26 08 PM

Please use ilike or regexp operator instead depending on your needs.

KalleV commented 1 year ago

@shubhamp-sf That’s true but the existing connector doesn’t throw an exception even if it is unused by the underlying MySQL connector. I was thinking for backwards compatibility / migration purposes it might be helpful if it was a no-op.