File tree Expand file tree Collapse file tree 3 files changed +27
-26
lines changed Expand file tree Collapse file tree 3 files changed +27
-26
lines changed Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ private class SQLiteEncoder: Encoder {
208
208
} else if let date = value as? Date {
209
209
encoder. setters. append ( Expression ( key. stringValue) <- date. datatypeValue)
210
210
} else if let uuid = value as? UUID {
211
- encoder. setters. append ( Expression ( key. stringValue) <- uuid. uuidString )
211
+ encoder. setters. append ( Expression ( key. stringValue) <- uuid. datatypeValue )
212
212
} else {
213
213
let encoded = try JSONEncoder ( ) . encode ( value)
214
214
let string = String ( data: encoded, encoding: . utf8)
Original file line number Diff line number Diff line change @@ -26,29 +26,4 @@ class FoundationTests: XCTestCase {
26
26
XCTAssertEqual ( UUID ( uuidString: " 4ABE10C9-FF12-4CD4-90C1-4B429001BAD3 " ) , uuid)
27
27
}
28
28
29
- func testUUIDInsert( ) {
30
- struct Test : Codable {
31
- var uuid : UUID
32
- var string : String
33
- }
34
- let testUUID = UUID ( )
35
- let testValue = Test ( uuid: testUUID, string: " value " )
36
- let db = try ! Connection ( . temporary)
37
- try ! db. run ( table. create { t in
38
- t. column ( uuid)
39
- t. column ( string)
40
- }
41
- )
42
-
43
- let iQuery = try ! table. insert ( testValue)
44
- try ! db. run ( iQuery)
45
-
46
- let fQuery = table. filter ( uuid == testUUID)
47
- if let result = try ! db. pluck ( fQuery) {
48
- let testValueReturned = Test ( uuid: result [ uuid] , string: result [ string] )
49
- XCTAssertEqual ( testUUID, testValueReturned. uuid)
50
- } else {
51
- XCTFail ( " Search for uuid failed " )
52
- }
53
- }
54
29
}
Original file line number Diff line number Diff line change @@ -310,6 +310,32 @@ class QueryTests: XCTestCase {
310
310
}
311
311
#endif
312
312
313
+ func test_insert_and_search_for_UUID( ) {
314
+ struct Test : Codable {
315
+ var uuid : UUID
316
+ var string : String
317
+ }
318
+ let testUUID = UUID ( )
319
+ let testValue = Test ( uuid: testUUID, string: " value " )
320
+ let db = try ! Connection ( . temporary)
321
+ try ! db. run ( table. create { t in
322
+ t. column ( uuid)
323
+ t. column ( string)
324
+ }
325
+ )
326
+
327
+ let iQuery = try ! table. insert ( testValue)
328
+ try ! db. run ( iQuery)
329
+
330
+ let fQuery = table. filter ( uuid == testUUID)
331
+ if let result = try ! db. pluck ( fQuery) {
332
+ let testValueReturned = Test ( uuid: result [ uuid] , string: result [ string] )
333
+ XCTAssertEqual ( testUUID, testValueReturned. uuid)
334
+ } else {
335
+ XCTFail ( " Search for uuid failed " )
336
+ }
337
+ }
338
+
313
339
func test_upsert_withOnConflict_compilesInsertOrOnConflictExpression( ) {
314
340
assertSQL (
315
341
"""
You can’t perform that action at this time.
0 commit comments