From 596db46407dc4970d854e5083bfaa77ad2d7eb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 8 May 2025 12:47:21 +0200 Subject: [PATCH] Make FTS5Pattern.init(rawPattern:allowedColumns:) public Fix #1763 --- GRDB/FTS/FTS5Pattern.swift | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/GRDB/FTS/FTS5Pattern.swift b/GRDB/FTS/FTS5Pattern.swift index 045a409a1..90b1d0157 100644 --- a/GRDB/FTS/FTS5Pattern.swift +++ b/GRDB/FTS/FTS5Pattern.swift @@ -123,7 +123,25 @@ public struct FTS5Pattern: Sendable { try? self.init(rawPattern: "^\"" + tokens.joined(separator: " ") + "\"") } - init(rawPattern: String, allowedColumns: [String] = []) throws { + /// Creates a pattern from a raw pattern string. + /// + /// The pattern syntax is documented at + /// + /// For example: + /// + /// ```swift + /// // OK + /// let pattern = try FTS5Pattern(rawPattern: "and") + /// + /// // Throws an error: malformed MATCH expression: [AND] + /// let pattern = try FTS5Pattern(rawPattern: "AND") + /// ``` + /// + /// If the pattern tests for specific columns, you must pass those + /// columns in the `allowedColumns` parameter. + /// + /// - throws: A ``DatabaseError`` if the pattern has an invalid syntax. + public init(rawPattern: String, allowedColumns: [String] = []) throws { // Correctness above all: use SQLite to validate the pattern. // // Invalid patterns have SQLite return an error on the first