Skip to content

LIKEI operator not supported #50

Open

Description

@jmdobry

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]

Activity

  1. techniq commented on Jan 29, 2016

    @techniq
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions