@@ -117,7 +117,7 @@ public struct Tokenizer {
117
117
118
118
// https://sqlite.org/fts5.html#the_experimental_trigram_tokenizer
119
119
public static func Trigram( caseSensitive: Bool = false ) -> Tokenizer {
120
- return Tokenizer ( " trigram " , [ " case_sensitive " , caseSensitive ? " 1 " : " 0 " ] )
120
+ Tokenizer ( " trigram " , [ " case_sensitive " , caseSensitive ? " 1 " : " 0 " ] )
121
121
}
122
122
123
123
public static func Custom( _ name: String ) -> Tokenizer {
@@ -236,18 +236,12 @@ open class FTSConfig {
236
236
}
237
237
}
238
238
239
- @discardableResult mutating func append( _ key: String , value: CustomStringConvertible ? ) -> Options {
240
- append ( key, value: value? . description )
239
+ @discardableResult mutating func append( _ key: String , value: String ) -> Options {
240
+ append ( key, value: Expression < String > ( value) )
241
241
}
242
242
243
- @discardableResult mutating func append( _ key: String , value: String ? ) -> Options {
244
- append ( key, value: value. map { Expression < String > ( $0) } )
245
- }
246
-
247
- @discardableResult mutating func append( _ key: String , value: Expressible ? ) -> Options {
248
- if let value = value {
249
- arguments. append ( " = " . join ( [ Expression < Void > ( literal: key) , value] ) )
250
- }
243
+ @discardableResult mutating func append( _ key: String , value: Expressible ) -> Options {
244
+ arguments. append ( " = " . join ( [ Expression < Void > ( literal: key) , value] ) )
251
245
return self
252
246
}
253
247
}
@@ -256,26 +250,16 @@ open class FTSConfig {
256
250
/// Configuration for the [FTS4](https://www.sqlite.org/fts3.html) extension.
257
251
open class FTS4Config : FTSConfig {
258
252
/// [The matchinfo= option](https://www.sqlite.org/fts3.html#section_6_4)
259
- public enum MatchInfo : CustomStringConvertible {
253
+ public enum MatchInfo : String {
260
254
case fts3
261
- public var description : String {
262
- " fts3 "
263
- }
264
255
}
265
256
266
257
/// [FTS4 options](https://www.sqlite.org/fts3.html#fts4_options)
267
- public enum Order : CustomStringConvertible {
258
+ public enum Order : String {
268
259
/// Data structures are optimized for returning results in ascending order by docid (default)
269
260
case asc
270
261
/// FTS4 stores its data in such a way as to optimize returning results in descending order by docid.
271
262
case desc
272
-
273
- public var description : String {
274
- switch self {
275
- case . asc: return " asc "
276
- case . desc: return " desc "
277
- }
278
- }
279
263
}
280
264
281
265
var compressFunction : String ?
@@ -322,11 +306,21 @@ open class FTS4Config: FTSConfig {
322
306
for (column, _) in ( columnDefinitions. filter { $0. options. contains ( . unindexed) } ) {
323
307
options. append ( " notindexed " , value: column)
324
308
}
325
- options. append ( " languageid " , value: languageId)
326
- options. append ( " compress " , value: compressFunction)
327
- options. append ( " uncompress " , value: uncompressFunction)
328
- options. append ( " matchinfo " , value: matchInfo)
329
- options. append ( " order " , value: order)
309
+ if let languageId = languageId {
310
+ options. append ( " languageid " , value: languageId)
311
+ }
312
+ if let compressFunction = compressFunction {
313
+ options. append ( " compress " , value: compressFunction)
314
+ }
315
+ if let uncompressFunction = uncompressFunction {
316
+ options. append ( " uncompress " , value: uncompressFunction)
317
+ }
318
+ if let matchInfo = matchInfo {
319
+ options. append ( " matchinfo " , value: matchInfo. rawValue)
320
+ }
321
+ if let order = order {
322
+ options. append ( " order " , value: order. rawValue)
323
+ }
330
324
return options
331
325
}
332
326
}
0 commit comments