You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func fetchDocuments(_ db:Database)throws->[Document]{letpattern1:FTS5Pattern=...letpattern2:FTS5Pattern=...letcombinedRawPattern="(\(pattern1.rawPattern)) OR (\(pattern2.rawPattern))"letcombinedPattern=try db.makeFTS5Pattern(rawPattern: combinedRawPattern, forTable:"document")returntryDocument.matching(combinedPattern)}
As you see, a database connection is required in order to build a FTS5Pattern from a raw string. The goal was to validate FTS5 Column Filters and to fail early, at the pattern creation, instead of failing when the request is executed. Retrospectively, this was probably a mistake, because it is not very handy to have to wait for a connection.
Will you please tell if you can use this technique? If not, we'll relax the api. Your first proposal is interesting as well 👍
FTS5Pattern
is great but it's initializers don't cover all cases.e.g.
init?(matchingAnyTokenIn:)
covers "foo OR bar" andinit?(matchingAllTokensIn:)
covers "foo AND bar", but what about: "(foo OR bar) AND other"?In some cases you want a single pattern that does all of your matching, e.g.
ColumnExpression.match(_ pattern: GRDB.FTS5Pattern)
.Proposal 1:
"(foo OR bar) AND other" could be expressed like so:
Proposal 2:
Expose a
FTS5Pattern
.initializer that takesrawPattern
as an escape hatch, so that client code can construct the pattern.If you consider either proposal a good idea, I could prepare a PR.
Thanks for all of your hard work @groue .
The text was updated successfully, but these errors were encountered: