mozilla/mentat

[query] Support SQLite's LIKE for non-fulltext text searching

Open

#747 aberto em 18 de jun. de 2018

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)Rust (116 forks)github user discovery
A-queryenhancementhelp wanted

Métricas do repositório

Stars
 (1.661 stars)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

While implementing a rough clone of Firefox for iOS's logins handling, I noticed that we don't support SQLite's LIKE operator for non-fulltext text searching. That's what we use in Firefox for iOS, and I don't want to make some of these fields :db/fulltext true, so we should grow support for it. I'm thinking that it'll be a special filtering function, like:

[:find ?e :where
 [?e :credential/name ?t]
 [(string-contains ?t "pattern")]]

although there are a few subtleties. First, "pattern" can be a binding (which is well supported by SQLite). Second, the pattern can contain _ and %, which have special meaning to SQLite. It's easy to escape a constant pattern, but not so easy to escape a binding (coming from elsewhere in the query engine, i.e., another column). We could make escaping the responsibility of the consumer, but that's likely to lead to surprises.

As a first cut, we could only accept literal patterns, which we can escape (or not) and transform concretely.

Guia do colaborador