Skip to content

Crash when FTS searching with symbols/special characters #855

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

Closed
erikbye opened this issue Oct 24, 2018 · 3 comments
Closed

Crash when FTS searching with symbols/special characters #855

erikbye opened this issue Oct 24, 2018 · 3 comments

Comments

@erikbye
Copy link

erikbye commented Oct 24, 2018

I use FTS5 and I get a crash when attempting to search with various symbols, for instance, equal symbol (=).

Error message: Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: fts5: syntax error near "=" (code: 1)

Same thing with forward and backslash: Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: fts5: syntax error near "\" (code: 1)

File: Statement.swift

extension FailableIterator {
    public func next() -> Element? {
        return try! failableNext()
    }
}

My code:

let fts_results = DBManager.shared.cliptext_virtual.filter(DBManager.shared.cliptext_virtual.match("clip_text: \(searchString)*"))

I also tried without the variable searchString. Just "clip_text: =", escaping the = sign, wrapping it in single quotes, etc.

If I write the query as such: .match("clip_text: \"\(searchString)\"*"))
I no longer get a crash when searching for =, but I don't get a match either, only for words.

bindings: [Optional("clip_text: \"=\"*")]))

How should I go about searching for an exact phrase, containing characters like = and /? Say, the phrase "sum= /"

SQLite.swift version: 0.11.5

@ghost
Copy link

ghost commented Oct 21, 2020

Any news about this?

@BirkhoffLee
Copy link

Same in here, please update.

@jberkel
Copy link
Collaborator

jberkel commented Aug 24, 2021

The input is not automatically you quoted, you need to do this yourself. See #305

@jberkel jberkel closed this as completed Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants