mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Disallow FTS5 column matching against NULL
SQLite just throws a syntax error
This commit is contained in:
1 parent
836432c4ce
commit
48ef691897
2 files changed
+2
-8
No files matched your search
@@ -48,11 +48,8 @@ extension ColumnExpression {
|
||||
///
|
||||
/// // content MATCH '...'
|
||||
/// Column("content").match(pattern)
|
||||
///
|
||||
/// If the search pattern is nil, SQLite will evaluate the expression
|
||||
/// to false.
|
||||
public func match(_ pattern: FTS5Pattern?) -> SQLExpression {
|
||||
.binary(.match, sqlExpression, pattern?.sqlExpression ?? .null)
|
||||
public func match(_ pattern: FTS5Pattern) -> SQLExpression {
|
||||
.binary(.match, sqlExpression, pattern.sqlExpression)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -89,9 +89,6 @@ class FTS5RecordTests: GRDBTestCase {
|
||||
let pattern = FTS5Pattern(matchingAllTokensIn: "")
|
||||
XCTAssertTrue(pattern == nil)
|
||||
XCTAssertEqual(try Book.matching(pattern).fetchCount(db), 0)
|
||||
XCTAssertEqual(try Book.filter(Column("books").match(pattern)).fetchCount(db), 0)
|
||||
XCTAssertEqual(try Book.filter(Column("author").match(pattern)).fetchCount(db), 0)
|
||||
XCTAssertEqual(try Book.filter(Column("title").match(pattern)).fetchCount(db), 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user