@@ -2,7 +2,9 @@ import IssueReporting
22
33/// A virtual table using the FTS5 extension.
44///
5- /// Apply this protocol to a `@Table` declaration to introduce FTS5 helpers.
5+ /// Apply this protocol to a `@Table` declaration to introduce [FTS5] helpers.
6+ ///
7+ /// [FTS5]: https://www.sqlite.org/fts5.html
68public protocol FTS5 : Table { }
79
810extension TableDefinition where QueryValue: FTS5 {
@@ -13,6 +15,16 @@ extension TableDefinition where QueryValue: FTS5 {
1315 /// // SELECT … FROM "reminderTexts" WHERE ("reminderTexts" MATCH 'get')
1416 /// ```
1517 ///
18+ /// > Important: Avoid passing a string entered by the user directly to this operator. FTS5
19+ /// > queries have a distinct [syntax] that can specify particular columns and refine a search in
20+ /// > various ways. If FTS5 is given a query with invalid syntax, it can even throw SQL errors at
21+ /// > runtime.
22+ /// >
23+ /// > Instead, consider transforming the user's input into a query by quoting, prefixing, and/or
24+ /// > combining inputs from your UI into a valid query before handing it off to SQLite.
25+ ///
26+ /// [syntax]: https://www.sqlite.org/fts5.html#full_text_query_syntax
27+ ///
1628 /// - Parameter pattern: A string expression describing the `MATCH` pattern.
1729 /// - Returns: A predicate expression.
1830 public func match( _ pattern: some StringProtocol ) -> some QueryExpression < Bool > {
@@ -60,7 +72,7 @@ extension TableColumnExpression where Root: FTS5 {
6072 ///
6173 /// ```swift
6274 /// ReminderText.where { $0.title.match("get") }
63- /// // SELECT … FROM "reminderTexts" WHERE ("reminderTexts"."title" MATCH 'get')
75+ /// // SELECT … FROM "reminderTexts" WHERE ("reminderTexts" MATCH 'title:\" get\" ')
6476 /// ```
6577 ///
6678 /// - Parameter pattern: A string expression describing the `MATCH` pattern.
0 commit comments