@@ -44,7 +44,7 @@ extension QueryType {
44
44
try encodable. encode ( to: encoder)
45
45
return self . insert ( encoder. setters + otherSetters)
46
46
}
47
-
47
+
48
48
/// Creates an `INSERT` statement by encoding the given object
49
49
/// This method converts any custom nested types to JSON data and does not handle any sort
50
50
/// of object relationships. If you want to support relationships between objects you will
@@ -69,7 +69,7 @@ extension QueryType {
69
69
try encodable. encode ( to: encoder)
70
70
return self . insert ( or: onConflict, encoder. setters + otherSetters)
71
71
}
72
-
72
+
73
73
/// Creates a batch `INSERT` statement by encoding the array of given objects
74
74
/// This method converts any custom nested types to JSON data and does not handle any sort
75
75
/// of object relationships. If you want to support relationships between objects you will
@@ -93,7 +93,7 @@ extension QueryType {
93
93
}
94
94
return self . insertMany ( combinedSetters)
95
95
}
96
-
96
+
97
97
/// Creates an `INSERT ON CONFLICT DO UPDATE` statement, aka upsert, by encoding the given object
98
98
/// This method converts any custom nested types to JSON data and does not handle any sort
99
99
/// of object relationships. If you want to support relationships between objects you will
@@ -116,7 +116,7 @@ extension QueryType {
116
116
try encodable. encode ( to: encoder)
117
117
return self . upsert ( encoder. setters + otherSetters, onConflictOf: conflicting)
118
118
}
119
-
119
+
120
120
/// Creates an `UPDATE` statement by encoding the given object
121
121
/// This method converts any custom nested types to JSON data and does not handle any sort
122
122
/// of object relationships. If you want to support relationships between objects you will
@@ -151,7 +151,7 @@ extension Row {
151
151
public func decode< V: Decodable > ( userInfo: [ CodingUserInfoKey : Any ] = [ : ] ) throws -> V {
152
152
try V ( from: decoder ( userInfo: userInfo) )
153
153
}
154
-
154
+
155
155
public func decoder( userInfo: [ CodingUserInfoKey : Any ] = [ : ] ) -> Decoder {
156
156
SQLiteDecoder ( row: self , userInfo: userInfo)
157
157
}
@@ -162,46 +162,46 @@ private class SQLiteEncoder: Encoder {
162
162
class SQLiteKeyedEncodingContainer < MyKey: CodingKey > : KeyedEncodingContainerProtocol {
163
163
// swiftlint:disable nesting
164
164
typealias Key = MyKey
165
-
165
+
166
166
let encoder : SQLiteEncoder
167
167
let codingPath : [ CodingKey ] = [ ]
168
-
168
+
169
169
init ( encoder: SQLiteEncoder ) {
170
170
self . encoder = encoder
171
171
}
172
-
172
+
173
173
func superEncoder( ) -> Swift . Encoder {
174
174
fatalError ( " SQLiteEncoding does not support super encoders " )
175
175
}
176
-
176
+
177
177
func superEncoder( forKey key: Key ) -> Swift . Encoder {
178
178
fatalError ( " SQLiteEncoding does not support super encoders " )
179
179
}
180
-
180
+
181
181
func encodeNil( forKey key: SQLiteEncoder . SQLiteKeyedEncodingContainer < Key > . Key ) throws {
182
182
encoder. setters. append ( Expression < String ? > ( key. stringValue) <- nil )
183
183
}
184
-
184
+
185
185
func encode( _ value: Int , forKey key: SQLiteEncoder . SQLiteKeyedEncodingContainer < Key > . Key ) throws {
186
186
encoder. setters. append ( Expression ( key. stringValue) <- value)
187
187
}
188
-
188
+
189
189
func encode( _ value: Bool , forKey key: Key ) throws {
190
190
encoder. setters. append ( Expression ( key. stringValue) <- value)
191
191
}
192
-
192
+
193
193
func encode( _ value: Float , forKey key: Key ) throws {
194
194
encoder. setters. append ( Expression ( key. stringValue) <- Double ( value) )
195
195
}
196
-
196
+
197
197
func encode( _ value: Double , forKey key: Key ) throws {
198
198
encoder. setters. append ( Expression ( key. stringValue) <- value)
199
199
}
200
-
200
+
201
201
func encode( _ value: String , forKey key: Key ) throws {
202
202
encoder. setters. append ( Expression ( key. stringValue) <- value)
203
203
}
204
-
204
+
205
205
func encode< T> ( _ value: T , forKey key: Key ) throws where T: Swift . Encodable {
206
206
switch value {
207
207
case let data as Data :
@@ -216,77 +216,77 @@ private class SQLiteEncoder: Encoder {
216
216
encoder. setters. append ( Expression ( key. stringValue) <- string)
217
217
}
218
218
}
219
-
219
+
220
220
func encode( _ value: Int8 , forKey key: Key ) throws {
221
221
throw EncodingError . invalidValue ( value, EncodingError . Context ( codingPath: codingPath,
222
222
debugDescription: " encoding an Int8 is not supported " ) )
223
223
}
224
-
224
+
225
225
func encode( _ value: Int16 , forKey key: Key ) throws {
226
226
throw EncodingError . invalidValue ( value, EncodingError . Context ( codingPath: codingPath,
227
227
debugDescription: " encoding an Int16 is not supported " ) )
228
228
}
229
-
229
+
230
230
func encode( _ value: Int32 , forKey key: Key ) throws {
231
231
throw EncodingError . invalidValue ( value, EncodingError . Context ( codingPath: codingPath,
232
232
debugDescription: " encoding an Int32 is not supported " ) )
233
233
}
234
-
234
+
235
235
func encode( _ value: Int64 , forKey key: Key ) throws {
236
236
encoder. setters. append ( Expression ( key. stringValue) <- value)
237
237
}
238
-
238
+
239
239
func encode( _ value: UInt , forKey key: Key ) throws {
240
240
throw EncodingError . invalidValue ( value, EncodingError . Context ( codingPath: codingPath,
241
241
debugDescription: " encoding an UInt is not supported " ) )
242
242
}
243
-
243
+
244
244
func encode( _ value: UInt8 , forKey key: Key ) throws {
245
245
throw EncodingError . invalidValue ( value, EncodingError . Context ( codingPath: codingPath,
246
246
debugDescription: " encoding an UInt8 is not supported " ) )
247
247
}
248
-
248
+
249
249
func encode( _ value: UInt16 , forKey key: Key ) throws {
250
250
throw EncodingError . invalidValue ( value, EncodingError . Context ( codingPath: codingPath,
251
251
debugDescription: " encoding an UInt16 is not supported " ) )
252
252
}
253
-
253
+
254
254
func encode( _ value: UInt32 , forKey key: Key ) throws {
255
255
throw EncodingError . invalidValue ( value, EncodingError . Context ( codingPath: codingPath,
256
256
debugDescription: " encoding an UInt32 is not supported " ) )
257
257
}
258
-
258
+
259
259
func encode( _ value: UInt64 , forKey key: Key ) throws {
260
260
throw EncodingError . invalidValue ( value, EncodingError . Context ( codingPath: codingPath,
261
261
debugDescription: " encoding an UInt64 is not supported " ) )
262
262
}
263
-
263
+
264
264
func nestedContainer< NestedKey> ( keyedBy keyType: NestedKey . Type , forKey key: Key )
265
265
-> KeyedEncodingContainer < NestedKey > where NestedKey: CodingKey {
266
266
fatalError ( " encoding a nested container is not supported " )
267
267
}
268
-
268
+
269
269
func nestedUnkeyedContainer( forKey key: Key ) -> UnkeyedEncodingContainer {
270
270
fatalError ( " encoding nested values is not supported " )
271
271
}
272
272
}
273
-
273
+
274
274
fileprivate var setters : [ Setter ] = [ ]
275
275
let codingPath : [ CodingKey ] = [ ]
276
276
let userInfo : [ CodingUserInfoKey : Any ]
277
-
277
+
278
278
init ( userInfo: [ CodingUserInfoKey : Any ] ) {
279
279
self . userInfo = userInfo
280
280
}
281
-
281
+
282
282
func singleValueContainer( ) -> SingleValueEncodingContainer {
283
283
fatalError ( " not supported " )
284
284
}
285
-
285
+
286
286
func unkeyedContainer( ) -> UnkeyedEncodingContainer {
287
287
fatalError ( " not supported " )
288
288
}
289
-
289
+
290
290
func container< Key> ( keyedBy type: Key . Type ) -> KeyedEncodingContainer < Key > where Key: CodingKey {
291
291
KeyedEncodingContainer ( SQLiteKeyedEncodingContainer ( encoder: self ) )
292
292
}
@@ -295,91 +295,91 @@ private class SQLiteEncoder: Encoder {
295
295
private class SQLiteDecoder : Decoder {
296
296
class SQLiteKeyedDecodingContainer < MyKey: CodingKey > : KeyedDecodingContainerProtocol {
297
297
typealias Key = MyKey
298
-
298
+
299
299
let codingPath : [ CodingKey ] = [ ]
300
300
let row : Row
301
-
301
+
302
302
init ( row: Row ) {
303
303
self . row = row
304
304
}
305
-
305
+
306
306
var allKeys : [ Key ] {
307
307
row. columnNames. keys. compactMap ( { Key ( stringValue: $0) } )
308
308
}
309
-
309
+
310
310
func contains( _ key: Key ) -> Bool {
311
311
row. hasValue ( for: key. stringValue)
312
312
}
313
-
313
+
314
314
func decodeNil( forKey key: Key ) throws -> Bool {
315
315
!contains( key)
316
316
}
317
-
317
+
318
318
func decode( _ type: Bool . Type , forKey key: Key ) throws -> Bool {
319
319
try row. get ( Expression ( key. stringValue) )
320
320
}
321
-
321
+
322
322
func decode( _ type: Int . Type , forKey key: Key ) throws -> Int {
323
323
try row. get ( Expression ( key. stringValue) )
324
324
}
325
-
325
+
326
326
func decode( _ type: Int8 . Type , forKey key: Key ) throws -> Int8 {
327
327
throw DecodingError . typeMismatch ( type, DecodingError . Context ( codingPath: codingPath,
328
328
debugDescription: " decoding an Int8 is not supported " ) )
329
329
}
330
-
330
+
331
331
func decode( _ type: Int16 . Type , forKey key: Key ) throws -> Int16 {
332
332
throw DecodingError . typeMismatch ( type, DecodingError . Context ( codingPath: codingPath,
333
333
debugDescription: " decoding an Int16 is not supported " ) )
334
334
}
335
-
335
+
336
336
func decode( _ type: Int32 . Type , forKey key: Key ) throws -> Int32 {
337
337
throw DecodingError . typeMismatch ( type, DecodingError . Context ( codingPath: codingPath,
338
338
debugDescription: " decoding an Int32 is not supported " ) )
339
339
}
340
-
340
+
341
341
func decode( _ type: Int64 . Type , forKey key: Key ) throws -> Int64 {
342
342
try row. get ( Expression ( key. stringValue) )
343
343
}
344
-
344
+
345
345
func decode( _ type: UInt . Type , forKey key: Key ) throws -> UInt {
346
346
throw DecodingError . typeMismatch ( type, DecodingError . Context ( codingPath: codingPath,
347
347
debugDescription: " decoding an UInt is not supported " ) )
348
-
348
+
349
349
}
350
-
350
+
351
351
func decode( _ type: UInt8 . Type , forKey key: Key ) throws -> UInt8 {
352
352
throw DecodingError . typeMismatch ( type, DecodingError . Context ( codingPath: codingPath,
353
353
debugDescription: " decoding an UInt8 is not supported " ) )
354
354
}
355
-
355
+
356
356
func decode( _ type: UInt16 . Type , forKey key: Key ) throws -> UInt16 {
357
357
throw DecodingError . typeMismatch ( type, DecodingError . Context ( codingPath: codingPath,
358
358
debugDescription: " decoding an UInt16 is not supported " ) )
359
359
}
360
-
360
+
361
361
func decode( _ type: UInt32 . Type , forKey key: Key ) throws -> UInt32 {
362
362
throw DecodingError . typeMismatch ( type, DecodingError . Context ( codingPath: codingPath,
363
363
debugDescription: " decoding an UInt32 is not supported " ) )
364
364
}
365
-
365
+
366
366
func decode( _ type: UInt64 . Type , forKey key: Key ) throws -> UInt64 {
367
367
throw DecodingError . typeMismatch ( type, DecodingError . Context ( codingPath: codingPath,
368
368
debugDescription: " decoding an UInt64 is not supported " ) )
369
369
}
370
-
370
+
371
371
func decode( _ type: Float . Type , forKey key: Key ) throws -> Float {
372
372
Float ( try row. get ( Expression < Double > ( key. stringValue) ) )
373
373
}
374
-
374
+
375
375
func decode( _ type: Double . Type , forKey key: Key ) throws -> Double {
376
376
try row. get ( Expression ( key. stringValue) )
377
377
}
378
-
378
+
379
379
func decode( _ type: String . Type , forKey key: Key ) throws -> String {
380
380
try row. get ( Expression ( key. stringValue) )
381
381
}
382
-
382
+
383
383
func decode< T> ( _ type: T . Type , forKey key: Key ) throws -> T where T: Swift . Decodable {
384
384
// swiftlint:disable force_cast
385
385
switch type {
@@ -405,47 +405,47 @@ private class SQLiteDecoder: Decoder {
405
405
return try JSONDecoder ( ) . decode ( type, from: data)
406
406
}
407
407
}
408
-
408
+
409
409
func nestedContainer< NestedKey> ( keyedBy type: NestedKey . Type , forKey key: Key ) throws
410
410
-> KeyedDecodingContainer < NestedKey > where NestedKey: CodingKey {
411
411
throw DecodingError . dataCorrupted ( DecodingError . Context ( codingPath: codingPath,
412
412
debugDescription: " decoding nested containers is not supported " ) )
413
413
}
414
-
414
+
415
415
func nestedUnkeyedContainer( forKey key: Key ) throws -> UnkeyedDecodingContainer {
416
416
throw DecodingError . dataCorrupted ( DecodingError . Context ( codingPath: codingPath,
417
417
debugDescription: " decoding unkeyed containers is not supported " ) )
418
418
}
419
-
419
+
420
420
func superDecoder( ) throws -> Swift . Decoder {
421
421
throw DecodingError . dataCorrupted ( DecodingError . Context ( codingPath: codingPath,
422
422
debugDescription: " decoding super encoders containers is not supported " ) )
423
423
}
424
-
424
+
425
425
func superDecoder( forKey key: Key ) throws -> Swift . Decoder {
426
426
throw DecodingError . dataCorrupted ( DecodingError . Context ( codingPath: codingPath,
427
427
debugDescription: " decoding super decoders is not supported " ) )
428
428
}
429
429
}
430
-
430
+
431
431
let row : Row
432
432
let codingPath : [ CodingKey ] = [ ]
433
433
let userInfo : [ CodingUserInfoKey : Any ]
434
-
434
+
435
435
init ( row: Row , userInfo: [ CodingUserInfoKey : Any ] ) {
436
436
self . row = row
437
437
self . userInfo = userInfo
438
438
}
439
-
439
+
440
440
func container< Key> ( keyedBy type: Key . Type ) throws -> KeyedDecodingContainer < Key > where Key: CodingKey {
441
441
KeyedDecodingContainer ( SQLiteKeyedDecodingContainer ( row: row) )
442
442
}
443
-
443
+
444
444
func unkeyedContainer( ) throws -> UnkeyedDecodingContainer {
445
445
throw DecodingError . dataCorrupted ( DecodingError . Context ( codingPath: codingPath,
446
446
debugDescription: " decoding an unkeyed container is not supported " ) )
447
447
}
448
-
448
+
449
449
func singleValueContainer( ) throws -> SingleValueDecodingContainer {
450
450
throw DecodingError . dataCorrupted ( DecodingError . Context ( codingPath: codingPath,
451
451
debugDescription: " decoding a single value container is not supported " ) )
0 commit comments