Expose remove_diacritics=2 option of unicode61 FTS tokenizer

This is because iOS 14 runs SQLite 3.31.1
This commit is contained in:
Gwendal Roué committed 2020-07-22 20:07:27 +02:00
1 parent 62f33e1d55
commit 294ed772c1
3 files changed
+24 -2

No files matched your search

+6
View File
@@ -21,6 +21,12 @@ public struct FTS3: VirtualTableModule {
/// option matches the raw "remove_diacritics=2" tokenizer argument,
/// available from SQLite 3.27.0
case remove
#elseif !GRDBCIPHER
/// Remove diacritics from Latin script characters. This
/// option matches the raw "remove_diacritics=2" tokenizer argument,
/// available from SQLite 3.27.0
@available(OSX 11, iOS 14, tvOS 14, watchOS 7, *)
case remove
#endif
}
+5 -2
View File
@@ -68,10 +68,13 @@ public struct FTS3TokenizerDescriptor {
break
case .keep:
arguments.append("remove_diacritics=0")
#if GRDBCUSTOMSQLITE
#if GRDBCUSTOMSQLITE
case .remove:
arguments.append("remove_diacritics=2")
#endif
#elseif !GRDBCIPHER
case .remove:
arguments.append("remove_diacritics=2")
#endif
}
if !separators.isEmpty {
// TODO: test "=" and "\"", "(" and ")" as separators, with
@@ -74,6 +74,19 @@ class FTS3TableBuilderTests: GRDBTestCase {
assertDidExecute(sql: "CREATE VIRTUAL TABLE \"documents\" USING fts3(tokenize=unicode61 \"remove_diacritics=2\")")
}
}
#elseif !GRDBCIPHER
func testUnicode61TokenizerDiacriticsRemove() throws {
guard #available(OSX 11, iOS 14, tvOS 14, watchOS 7, *) else {
throw XCTSkip()
}
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try db.create(virtualTable: "documents", using: FTS3()) { t in
t.tokenizer = .unicode61(diacritics: .remove)
}
assertDidExecute(sql: "CREATE VIRTUAL TABLE \"documents\" USING fts3(tokenize=unicode61 \"remove_diacritics=2\")")
}
}
#endif
func testUnicode61TokenizerSeparators() throws {