@@ -249,23 +249,23 @@ class QueryTests : XCTestCase {
249249
250250 func test_insert_encodable( ) throws {
251251 let emails = Table ( " emails " )
252- let value = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , optional: nil , sub: nil )
252+ let value = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , date : Date ( timeIntervalSince1970 : 0 ) , optional: nil , sub: nil )
253253 let insert = try emails. insert ( value)
254254 AssertSQL (
255- " INSERT INTO \" emails \" ( \" int \" , \" string \" , \" bool \" , \" float \" , \" double \" ) VALUES (1, '2', 1, 3.0, 4.0) " ,
255+ " INSERT INTO \" emails \" ( \" int \" , \" string \" , \" bool \" , \" float \" , \" double \" , \" date \" ) VALUES (1, '2', 1, 3.0, 4.0, '1970-01-01T00:00:00.000' ) " ,
256256 insert
257257 )
258258 }
259259
260260 func test_insert_encodable_with_nested_encodable( ) throws {
261261 let emails = Table ( " emails " )
262- let value1 = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , optional: nil , sub: nil )
263- let value = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , optional: " optional " , sub: value1)
262+ let value1 = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , date : Date ( timeIntervalSince1970 : 0 ) , optional: nil , sub: nil )
263+ let value = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , date : Date ( timeIntervalSince1970 : 0 ) , optional: " optional " , sub: value1)
264264 let insert = try emails. insert ( value)
265265 let encodedJSON = try JSONEncoder ( ) . encode ( value1)
266266 let encodedJSONString = String ( data: encodedJSON, encoding: . utf8) !
267267 AssertSQL (
268- " INSERT INTO \" emails \" ( \" int \" , \" string \" , \" bool \" , \" float \" , \" double \" , \" optional \" , \" sub \" ) VALUES (1, '2', 1, 3.0, 4.0, 'optional', ' \( encodedJSONString) ') " ,
268+ " INSERT INTO \" emails \" ( \" int \" , \" string \" , \" bool \" , \" float \" , \" double \" , \" date \" , \" optional \" , \" sub \" ) VALUES (1, '2', 1, 3.0, 4.0, '1970-01-01T00:00:00.000' , 'optional', ' \( encodedJSONString) ') " ,
269269 insert
270270 )
271271 }
@@ -286,23 +286,23 @@ class QueryTests : XCTestCase {
286286
287287 func test_update_encodable( ) throws {
288288 let emails = Table ( " emails " )
289- let value = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , optional: nil , sub: nil )
289+ let value = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , date : Date ( timeIntervalSince1970 : 0 ) , optional: nil , sub: nil )
290290 let update = try emails. update ( value)
291291 AssertSQL (
292- " UPDATE \" emails \" SET \" int \" = 1, \" string \" = '2', \" bool \" = 1, \" float \" = 3.0, \" double \" = 4.0 " ,
292+ " UPDATE \" emails \" SET \" int \" = 1, \" string \" = '2', \" bool \" = 1, \" float \" = 3.0, \" double \" = 4.0, \" date \" = '1970-01-01T00:00:00.000' " ,
293293 update
294294 )
295295 }
296296
297297 func test_update_encodable_with_nested_encodable( ) throws {
298298 let emails = Table ( " emails " )
299- let value1 = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , optional: nil , sub: nil )
300- let value = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , optional: nil , sub: value1)
299+ let value1 = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , date : Date ( timeIntervalSince1970 : 0 ) , optional: nil , sub: nil )
300+ let value = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , date : Date ( timeIntervalSince1970 : 0 ) , optional: nil , sub: value1)
301301 let update = try emails. update ( value)
302302 let encodedJSON = try JSONEncoder ( ) . encode ( value1)
303303 let encodedJSONString = String ( data: encodedJSON, encoding: . utf8) !
304304 AssertSQL (
305- " UPDATE \" emails \" SET \" int \" = 1, \" string \" = '2', \" bool \" = 1, \" float \" = 3.0, \" double \" = 4.0, \" sub \" = ' \( encodedJSONString) ' " ,
305+ " UPDATE \" emails \" SET \" int \" = 1, \" string \" = '2', \" bool \" = 1, \" float \" = 3.0, \" double \" = 4.0, \" date \" = '1970-01-01T00:00:00.000', \" sub \" = ' \( encodedJSONString) ' " ,
306306 update
307307 )
308308 }
@@ -438,12 +438,13 @@ class QueryIntegrationTests : SQLiteTestCase {
438438 builder. column ( Expression < Bool > ( " bool " ) )
439439 builder. column ( Expression < Double > ( " float " ) )
440440 builder. column ( Expression < Double > ( " double " ) )
441+ builder. column ( Expression < Date > ( " date " ) )
441442 builder. column ( Expression < String ? > ( " optional " ) )
442443 builder. column ( Expression < Data > ( " sub " ) )
443444 } )
444445
445- let value1 = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , optional: nil , sub: nil )
446- let value = TestCodable ( int: 5 , string: " 6 " , bool: true , float: 7 , double: 8 , optional: " optional " , sub: value1)
446+ let value1 = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 , date : Date ( timeIntervalSince1970 : 0 ) , optional: nil , sub: nil )
447+ let value = TestCodable ( int: 5 , string: " 6 " , bool: true , float: 7 , double: 8 , date : Date ( timeIntervalSince1970 : 5000 ) , optional: " optional " , sub: value1)
447448
448449 try db. run ( table. insert ( value) )
449450
@@ -455,12 +456,14 @@ class QueryIntegrationTests : SQLiteTestCase {
455456 XCTAssertEqual ( values [ 0 ] . bool, true )
456457 XCTAssertEqual ( values [ 0 ] . float, 7 )
457458 XCTAssertEqual ( values [ 0 ] . double, 8 )
459+ XCTAssertEqual ( values [ 0 ] . date, Date ( timeIntervalSince1970: 5000 ) )
458460 XCTAssertEqual ( values [ 0 ] . optional, " optional " )
459461 XCTAssertEqual ( values [ 0 ] . sub? . int, 1 )
460462 XCTAssertEqual ( values [ 0 ] . sub? . string, " 2 " )
461463 XCTAssertEqual ( values [ 0 ] . sub? . bool, true )
462464 XCTAssertEqual ( values [ 0 ] . sub? . float, 3 )
463465 XCTAssertEqual ( values [ 0 ] . sub? . double, 4 )
466+ XCTAssertEqual ( values [ 0 ] . sub? . date, Date ( timeIntervalSince1970: 0 ) )
464467 XCTAssertNil ( values [ 0 ] . sub? . optional)
465468 XCTAssertNil ( values [ 0 ] . sub? . sub)
466469 }
0 commit comments