loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

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

Open KalleV opened this issue 1 year ago • 2 comments

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:

  • https://loopback.io/doc/en/lb4/Where-filter.html#operators

Logs

No response

Additional information

No response

Reproduction

N/A

KalleV avatar Jun 24 '23 14:06 KalleV

@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.

shubhamp-sf avatar Jun 25 '23 06:06 shubhamp-sf

@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.

KalleV avatar Jun 30 '23 00:06 KalleV