Skip to content

Commit 596db46

Browse files
committed
Make FTS5Pattern.init(rawPattern:allowedColumns:) public
Fix groue#1763
1 parent 0aaa2a4 commit 596db46

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

GRDB/FTS/FTS5Pattern.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,25 @@ public struct FTS5Pattern: Sendable {
123123
try? self.init(rawPattern: "^\"" + tokens.joined(separator: " ") + "\"")
124124
}
125125

126-
init(rawPattern: String, allowedColumns: [String] = []) throws {
126+
/// Creates a pattern from a raw pattern string.
127+
///
128+
/// The pattern syntax is documented at <https://www.sqlite.org/fts5.html#full_text_query_syntax>
129+
///
130+
/// For example:
131+
///
132+
/// ```swift
133+
/// // OK
134+
/// let pattern = try FTS5Pattern(rawPattern: "and")
135+
///
136+
/// // Throws an error: malformed MATCH expression: [AND]
137+
/// let pattern = try FTS5Pattern(rawPattern: "AND")
138+
/// ```
139+
///
140+
/// If the pattern tests for specific columns, you must pass those
141+
/// columns in the `allowedColumns` parameter.
142+
///
143+
/// - throws: A ``DatabaseError`` if the pattern has an invalid syntax.
144+
public init(rawPattern: String, allowedColumns: [String] = []) throws {
127145
// Correctness above all: use SQLite to validate the pattern.
128146
//
129147
// Invalid patterns have SQLite return an error on the first

0 commit comments

Comments
 (0)