Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIKEI operator not supported #50

Open
jmdobry opened this issue Jan 7, 2016 · 1 comment
Open

LIKEI operator not supported #50

jmdobry opened this issue Jan 7, 2016 · 1 comment
Labels

Comments

@jmdobry
Copy link
Member

jmdobry commented Jan 7, 2016

Regarding to this documentation LIKEI operator should be supported

http://www.js-data.io/docs/query-syntax

but it is not - at least for DSSqlAdapter (PostgreSQL)

Error is : ERR [Error: Operator not found]

@techniq
Copy link
Member

techniq commented Jan 29, 2016

We could use something like WHERE LOWER(name) LIKE LOWER('%foo%') but this will not use indexes

It looks like Postgres has the case insenstive ILIKE but it is not in the SQL standard but is an extension. Also not sure about index use.

MySQL has WHERE name COLLATE UTF8_GENERAL_CI LIKE '%foo%' but not sure if it will still use an index if available or if it's just as bad as the lower option.

Until it's decided how best to handle this, as of version 0.11.10, you can register a custom query operator and provide your own implementation (or override an existing one)

For example, this should work to use ILIKE on postgres (untested though)

var adapter = new DSSqlAdapter({
  client: 'pg',
  queryOperators: {
    'likei': (query, field, value) => query.where(field, 'ilike', value),
    '|likei': (query, field, value) => query.orWhere(field, 'ilike', value)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants