mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Xcode 8 WIP
This commit is contained in:
1 parent
0944ed331b
commit
cd820c2dbe
4 files changed
+73
-4
No files matched your search
@@ -244,6 +244,18 @@
|
||||
56553C101C3E906C00522B5C /* GRDBTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5623E0901B4AFACC00B20B7F /* GRDBTestCase.swift */; };
|
||||
56553C121C3E906C00522B5C /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 56BB86301BA98AB0001F9168 /* libsqlite3.tbd */; };
|
||||
56553C131C3E906C00522B5C /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC3773F319C8CBB3004FCF85 /* GRDB.framework */; };
|
||||
5657AAAA1D106E39006283EF /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAA91D106E39006283EF /* NSDate.swift */; };
|
||||
5657AAAB1D106E39006283EF /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAA91D106E39006283EF /* NSDate.swift */; };
|
||||
5657AAAC1D106E39006283EF /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAA91D106E39006283EF /* NSDate.swift */; };
|
||||
5657AAAD1D106E39006283EF /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAA91D106E39006283EF /* NSDate.swift */; };
|
||||
5657AAAE1D106E39006283EF /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAA91D106E39006283EF /* NSDate.swift */; };
|
||||
5657AAAF1D106E39006283EF /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAA91D106E39006283EF /* NSDate.swift */; };
|
||||
5657AAB91D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; };
|
||||
5657AABA1D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; };
|
||||
5657AABB1D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; };
|
||||
5657AABC1D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; };
|
||||
5657AABD1D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; };
|
||||
5657AABE1D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; };
|
||||
565B0FEF1BBC7D980098DE03 /* RowConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565B0FEE1BBC7D980098DE03 /* RowConvertibleTests.swift */; };
|
||||
565B0FF01BBC7D980098DE03 /* RowConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565B0FEE1BBC7D980098DE03 /* RowConvertibleTests.swift */; };
|
||||
565D5D711BBC694D00DC9BD4 /* Row+FoundationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565D5D701BBC694D00DC9BD4 /* Row+FoundationTests.swift */; };
|
||||
@@ -1272,6 +1284,8 @@
|
||||
564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollationTests.swift; sourceTree = "<group>"; };
|
||||
565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchedRecordsControllerTests.swift; sourceTree = "<group>"; };
|
||||
56553C181C3E906C00522B5C /* GRDBOSXCrashTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXCrashTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5657AAA91D106E39006283EF /* NSDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDate.swift; sourceTree = "<group>"; };
|
||||
5657AAB81D107001006283EF /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSData.swift; sourceTree = "<group>"; };
|
||||
565B0FEE1BBC7D980098DE03 /* RowConvertibleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowConvertibleTests.swift; sourceTree = "<group>"; };
|
||||
565D5D701BBC694D00DC9BD4 /* Row+FoundationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+FoundationTests.swift"; sourceTree = "<group>"; };
|
||||
565D5D731BBC70AE00DC9BD4 /* StatementArguments+FoundationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StatementArguments+FoundationTests.swift"; sourceTree = "<group>"; };
|
||||
@@ -1591,6 +1605,8 @@
|
||||
5605F14C1C672E4000235C62 /* DatabaseDateComponents.swift */,
|
||||
5605F14D1C672E4000235C62 /* DatabaseValue+Foundation.swift */,
|
||||
5605F14F1C672E4000235C62 /* Date.swift */,
|
||||
5657AAB81D107001006283EF /* NSData.swift */,
|
||||
5657AAA91D106E39006283EF /* NSDate.swift */,
|
||||
5605F1501C672E4000235C62 /* NSNull.swift */,
|
||||
5605F1511C672E4000235C62 /* NSNumber.swift */,
|
||||
5605F1521C672E4000235C62 /* NSString.swift */,
|
||||
@@ -2952,6 +2968,7 @@
|
||||
560FC5381CB003810014AA8E /* DatabaseDateComponents.swift in Sources */,
|
||||
56193E961CD8A3E300F95862 /* FetchedRecordsController.swift in Sources */,
|
||||
560FC5391CB003810014AA8E /* DatabaseReader.swift in Sources */,
|
||||
5657AAAB1D106E39006283EF /* NSDate.swift in Sources */,
|
||||
5687358D1CEDC334009B9116 /* FetchRequest.swift in Sources */,
|
||||
560FC53A1CB003810014AA8E /* NSNull.swift in Sources */,
|
||||
560FC53B1CB003810014AA8E /* Database.swift in Sources */,
|
||||
@@ -2961,6 +2978,7 @@
|
||||
560FC53F1CB003810014AA8E /* Row.swift in Sources */,
|
||||
560FC5401CB003810014AA8E /* StandardLibrary.swift in Sources */,
|
||||
560FC5411CB003810014AA8E /* Persistable.swift in Sources */,
|
||||
5657AABA1D107001006283EF /* NSData.swift in Sources */,
|
||||
560FC5421CB003810014AA8E /* StatementColumnConvertible.swift in Sources */,
|
||||
560FC5431CB003810014AA8E /* RowConvertible.swift in Sources */,
|
||||
);
|
||||
@@ -3201,6 +3219,7 @@
|
||||
56AFCA0D1CB1A8BB00F48B96 /* DatabaseDateComponents.swift in Sources */,
|
||||
56AFCA0E1CB1A8BB00F48B96 /* DatabaseReader.swift in Sources */,
|
||||
56AFCA0F1CB1A8BB00F48B96 /* NSNull.swift in Sources */,
|
||||
5657AAAE1D106E39006283EF /* NSDate.swift in Sources */,
|
||||
5687358F1CEDC334009B9116 /* FetchRequest.swift in Sources */,
|
||||
56AFCA101CB1A8BB00F48B96 /* DatabaseQueue.swift in Sources */,
|
||||
56AFCA111CB1A8BB00F48B96 /* DatabaseError.swift in Sources */,
|
||||
@@ -3210,6 +3229,7 @@
|
||||
56AFCA151CB1A8BB00F48B96 /* Persistable.swift in Sources */,
|
||||
56AFCA161CB1A8BB00F48B96 /* StatementColumnConvertible.swift in Sources */,
|
||||
56AFCA171CB1A8BB00F48B96 /* RowConvertible.swift in Sources */,
|
||||
5657AABD1D107001006283EF /* NSData.swift in Sources */,
|
||||
56AFCA181CB1A8BB00F48B96 /* FetchedRecordsController.swift in Sources */,
|
||||
56AFCA191CB1A8BB00F48B96 /* DatabaseValue.swift in Sources */,
|
||||
);
|
||||
@@ -3436,6 +3456,7 @@
|
||||
5605F15E1C672E4000235C62 /* DatabaseDateComponents.swift in Sources */,
|
||||
563363C11C942C04000BE133 /* DatabaseReader.swift in Sources */,
|
||||
5605F1661C672E4000235C62 /* NSNull.swift in Sources */,
|
||||
5657AAAD1D106E39006283EF /* NSDate.swift in Sources */,
|
||||
5687358E1CEDC334009B9116 /* FetchRequest.swift in Sources */,
|
||||
56A238841B9C75030082EB20 /* DatabaseQueue.swift in Sources */,
|
||||
56A238821B9C75030082EB20 /* DatabaseError.swift in Sources */,
|
||||
@@ -3445,6 +3466,7 @@
|
||||
560D92481C672C4B00F4F92B /* Persistable.swift in Sources */,
|
||||
560D92431C672C3E00F4F92B /* StatementColumnConvertible.swift in Sources */,
|
||||
560D924A1C672C4B00F4F92B /* RowConvertible.swift in Sources */,
|
||||
5657AABC1D107001006283EF /* NSData.swift in Sources */,
|
||||
31A778841C6A4E0600F507F6 /* FetchedRecordsController.swift in Sources */,
|
||||
56A238861B9C75030082EB20 /* DatabaseValue.swift in Sources */,
|
||||
);
|
||||
@@ -3669,6 +3691,7 @@
|
||||
5605F15D1C672E4000235C62 /* DatabaseDateComponents.swift in Sources */,
|
||||
56193E8E1CD8A3E200F95862 /* FetchedRecordsController.swift in Sources */,
|
||||
563363C01C942C04000BE133 /* DatabaseReader.swift in Sources */,
|
||||
5657AAAA1D106E39006283EF /* NSDate.swift in Sources */,
|
||||
5687358C1CEDC334009B9116 /* FetchRequest.swift in Sources */,
|
||||
5605F1651C672E4000235C62 /* NSNull.swift in Sources */,
|
||||
56A2387D1B9C75030082EB20 /* Database.swift in Sources */,
|
||||
@@ -3678,6 +3701,7 @@
|
||||
56A238871B9C75030082EB20 /* Row.swift in Sources */,
|
||||
5605F1731C672E4000235C62 /* StandardLibrary.swift in Sources */,
|
||||
560D92471C672C4B00F4F92B /* Persistable.swift in Sources */,
|
||||
5657AAB91D107001006283EF /* NSData.swift in Sources */,
|
||||
560D92421C672C3E00F4F92B /* StatementColumnConvertible.swift in Sources */,
|
||||
560D92491C672C4B00F4F92B /* RowConvertible.swift in Sources */,
|
||||
);
|
||||
@@ -3721,6 +3745,7 @@
|
||||
F3BA80331CFB28A4003DC1BA /* Persistable.swift in Sources */,
|
||||
F3BA80351CFB28A4003DC1BA /* RowConvertible.swift in Sources */,
|
||||
F3BA80291CFB2895003DC1BA /* Utils.swift in Sources */,
|
||||
5657AAAF1D106E39006283EF /* NSDate.swift in Sources */,
|
||||
F3BA80251CFB288C003DC1BA /* Row+Foundation.swift in Sources */,
|
||||
F3BA80211CFB288C003DC1BA /* NSNull.swift in Sources */,
|
||||
F3BA80141CFB2876003DC1BA /* DatabaseValueConvertible.swift in Sources */,
|
||||
@@ -3730,6 +3755,7 @@
|
||||
F3BA80301CFB289F003DC1BA /* DatabaseMigrator.swift in Sources */,
|
||||
F3BA80361CFB28A4003DC1BA /* TableMapping.swift in Sources */,
|
||||
F3BA80271CFB2891003DC1BA /* RawRepresentable.swift in Sources */,
|
||||
5657AABE1D107001006283EF /* NSData.swift in Sources */,
|
||||
F3BA800E1CFB2876003DC1BA /* DatabaseQueue.swift in Sources */,
|
||||
F3BA80191CFB2876003DC1BA /* Statement.swift in Sources */,
|
||||
);
|
||||
@@ -3864,6 +3890,7 @@
|
||||
F3BA808F1CFB2E7A003DC1BA /* Persistable.swift in Sources */,
|
||||
F3BA80911CFB2E7A003DC1BA /* RowConvertible.swift in Sources */,
|
||||
F3BA80851CFB2E6C003DC1BA /* Utils.swift in Sources */,
|
||||
5657AAAC1D106E39006283EF /* NSDate.swift in Sources */,
|
||||
F3BA80811CFB2E61003DC1BA /* Row+Foundation.swift in Sources */,
|
||||
F3BA807D1CFB2E61003DC1BA /* NSNull.swift in Sources */,
|
||||
F3BA80701CFB2E55003DC1BA /* DatabaseValueConvertible.swift in Sources */,
|
||||
@@ -3873,6 +3900,7 @@
|
||||
F3BA808C1CFB2E75003DC1BA /* DatabaseMigrator.swift in Sources */,
|
||||
F3BA80921CFB2E7A003DC1BA /* TableMapping.swift in Sources */,
|
||||
F3BA80831CFB2E67003DC1BA /* RawRepresentable.swift in Sources */,
|
||||
5657AABB1D107001006283EF /* NSData.swift in Sources */,
|
||||
F3BA806A1CFB2E55003DC1BA /* DatabaseQueue.swift in Sources */,
|
||||
F3BA80751CFB2E55003DC1BA /* Statement.swift in Sources */,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import Foundation
|
||||
|
||||
/// NSData is convertible to and from DatabaseValue.
|
||||
extension NSData : DatabaseValueConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return (self as Data).databaseValue
|
||||
}
|
||||
|
||||
/// Returns an NSData initialized from *databaseValue*, if it contains
|
||||
/// a Blob.
|
||||
public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self? {
|
||||
if let data = Data.fromDatabaseValue(databaseValue) {
|
||||
return self.init(data: data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import Foundation
|
||||
|
||||
/// NSDate is stored in the database using the format
|
||||
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
|
||||
extension NSDate : DatabaseValueConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return (self as Date).databaseValue
|
||||
}
|
||||
|
||||
/// Returns an NSDate initialized from *databaseValue*, if possible.
|
||||
public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self? {
|
||||
if let date = Date.fromDatabaseValue(databaseValue) {
|
||||
return self.init(timeInterval: 0, since: date)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -20,23 +20,26 @@ class RowFoundationTests: GRDBTestCase {
|
||||
}
|
||||
|
||||
func testRowFromNSDictionary() {
|
||||
let dictionary: NSDictionary = ["a": "foo", "b": 1, "c": NSNull(), "d": NSDate(timeIntervalSince1970: 1443642439)]
|
||||
let dictionary: NSDictionary = ["a": "foo", "b": 1, "c": NSNull(), "d": NSDate(timeIntervalSince1970: 1443642439), "e": NSData(data: "foo".data(using: .utf8)!)]
|
||||
let row = Row(dictionary)!
|
||||
|
||||
XCTAssertEqual(row.count, 4)
|
||||
XCTAssertEqual(row.count, 5)
|
||||
XCTAssertEqual(row.value(named: "a") as String, "foo")
|
||||
XCTAssertEqual(row.value(named: "b") as Int, 1)
|
||||
XCTAssertTrue(row.databaseValue(named: "c")!.isNull)
|
||||
XCTAssertEqual(row.value(named: "d") as String, "2015-09-30 19:47:19.000")
|
||||
XCTAssertEqual(row.value(named: "e") as Data, "foo".data(using: .utf8))
|
||||
}
|
||||
|
||||
func testRowToNSDictionary() {
|
||||
let row = Row(["a": "foo", "b": 1, "c": nil, "d": Date(timeIntervalSince1970: 1443642439)])
|
||||
let data = "foo".data(using: .utf8)!
|
||||
let row = Row(["a": "foo", "b": 1, "c": nil, "d": Date(timeIntervalSince1970: 1443642439), "e": data])
|
||||
let dictionary = row.toNSDictionary()
|
||||
XCTAssertEqual(dictionary.count, 4)
|
||||
XCTAssertEqual(dictionary.count, 5)
|
||||
XCTAssertTrue((dictionary["a"] as! NSString).isEqual(to: "foo"))
|
||||
XCTAssertTrue((dictionary["b"] as! NSNumber).isEqual(to: NSNumber(value: 1)))
|
||||
XCTAssertTrue(dictionary["c"] is NSNull)
|
||||
XCTAssertTrue((dictionary["d"] as! NSString).isEqual(to: "2015-09-30 19:47:19.000"))
|
||||
XCTAssertTrue((dictionary["e"] as! NSData).isEqual(to: "foo".data(using: .utf8)!))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user