Skip to content

Commit

Permalink
Merge pull request #493 from groue/feature/SQLite-3.27.2
Browse files Browse the repository at this point in the history
Bump SQLite to 3.27.2
  • Loading branch information
groue authored Mar 5, 2019
2 parents 661cca9 + c20b7e5 commit 0363ca4
Show file tree
Hide file tree
Showing 18 changed files with 1,169 additions and 1,021 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
url = https://github.com/groue/sqlcipher.git
[submodule "SQLiteCustom/src"]
path = SQLiteCustom/src
url = https://github.com/swiftlyfalling/SQLiteLib
url = https://github.com/swiftlyfalling/SQLiteLib.git
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one expection:
- [#484](https://github.com/groue/GRDB.swift/pull/484): SE-0193 Cross-module inlining and specialization
- [#486](https://github.com/groue/GRDB.swift/pull/486): Refactor PersistenceError.recordNotFound
- [#488](https://github.com/groue/GRDB.swift/pull/488): ValueObservation Cleanup
- [#493](https://github.com/groue/GRDB.swift/pull/493): Bump SQLite to [3.27.2](https://www.sqlite.org/releaselog/3_27_2.html)

### Breaking Changes

Expand Down
19 changes: 19 additions & 0 deletions GRDB/FTS/FTS3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@
/// t.column("content")
/// }
public struct FTS3 : VirtualTableModule {
/// Options for Latin script characters. Matches the raw "remove_diacritics"
/// tokenizer argument.
///
/// See https://www.sqlite.org/fts3.html
public enum Diacritics {
/// Do not remove diacritics from Latin script characters. This
/// option matches the raw "remove_diacritics=0" tokenizer argument.
case keep
/// Remove diacritics from Latin script characters. This
/// option matches the raw "remove_diacritics=1" tokenizer argument.
case removeLegacy
#if GRDBCUSTOMSQLITE
/// Remove diacritics from Latin script characters. This
/// option matches the raw "remove_diacritics=2" tokenizer argument,
/// available from SQLite 3.27.0
case remove
#endif
}

/// Creates a FTS3 module suitable for the Database
/// `create(virtualTable:using:)` method.
///
Expand Down
27 changes: 17 additions & 10 deletions GRDB/FTS/FTS3TokenizerDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ public struct FTS3TokenizerDescriptor {
/// }
///
/// - parameters:
/// - removeDiacritics: If true (the default), then SQLite will strip
/// diacritics from latin characters.
/// - diacritics: By default SQLite will strip diacritics from
/// latin characters.
/// - separators: Unless empty (the default), SQLite will consider these
/// characters as token separators.
/// - tokenCharacters: Unless empty (the default), SQLite will consider
/// these characters as token characters.
///
/// See https://www.sqlite.org/fts3.html#tokenizer
public static func unicode61(removeDiacritics: Bool = true, separators: Set<Character> = [], tokenCharacters: Set<Character> = []) -> FTS3TokenizerDescriptor {
return _unicode61(removeDiacritics: removeDiacritics, separators: separators, tokenCharacters: tokenCharacters)
public static func unicode61(diacritics: FTS3.Diacritics = .removeLegacy, separators: Set<Character> = [], tokenCharacters: Set<Character> = []) -> FTS3TokenizerDescriptor {
return _unicode61(diacritics: diacritics, separators: separators, tokenCharacters: tokenCharacters)
}
#else
/// The "unicode61" tokenizer.
Expand All @@ -59,26 +59,33 @@ public struct FTS3TokenizerDescriptor {
/// }
///
/// - parameters:
/// - removeDiacritics: If true (the default), then SQLite will strip
/// diacritics from latin characters.
/// - diacritics: By default SQLite will strip diacritics from
/// latin characters.
/// - separators: Unless empty (the default), SQLite will consider these
/// characters as token separators.
/// - tokenCharacters: Unless empty (the default), SQLite will consider
/// these characters as token characters.
///
/// See https://www.sqlite.org/fts3.html#tokenizer
@available(OSX 10.10, *)
public static func unicode61(removeDiacritics: Bool = true, separators: Set<Character> = [], tokenCharacters: Set<Character> = []) -> FTS3TokenizerDescriptor {
public static func unicode61(diacritics: FTS3.Diacritics = .removeLegacy, separators: Set<Character> = [], tokenCharacters: Set<Character> = []) -> FTS3TokenizerDescriptor {
// query_only pragma was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
return _unicode61(removeDiacritics: removeDiacritics, separators: separators, tokenCharacters: tokenCharacters)
return _unicode61(diacritics: diacritics, separators: separators, tokenCharacters: tokenCharacters)
}
#endif

private static func _unicode61(removeDiacritics: Bool = true, separators: Set<Character> = [], tokenCharacters: Set<Character> = []) -> FTS3TokenizerDescriptor {
private static func _unicode61(diacritics: FTS3.Diacritics, separators: Set<Character> = [], tokenCharacters: Set<Character> = []) -> FTS3TokenizerDescriptor {
var arguments: [String] = []
if !removeDiacritics {
switch diacritics {
case .removeLegacy:
break
case .keep:
arguments.append("remove_diacritics=0")
#if GRDBCUSTOMSQLITE
case .remove:
arguments.append("remove_diacritics=2")
#endif
}
if !separators.isEmpty {
// TODO: test "=" and "\"", "(" and ")" as separators, with both FTS3Pattern(matchingAnyTokenIn:tokenizer:) and Database.create(virtualTable:using:)
Expand Down
Loading

0 comments on commit 0363ca4

Please sign in to comment.