Skip to content

Commit 05af27b

Browse files
authored
Merge branch 'master' into vision-os
2 parents 5bfaddf + 4ab2748 commit 05af27b

File tree

6 files changed

+69
-9
lines changed

6 files changed

+69
-9
lines changed

SQLite.xcodeproj/project.pbxproj

+16
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@
281281
DEB307092B61CF9500F9D46B /* Connection+AttachTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A170C08525D3D27CB5F83C /* Connection+AttachTests.swift */; };
282282
DEB3070B2B61CF9500F9D46B /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03A65E5A1C6BB0F50062603F /* SQLite.framework */; };
283283
DEB3070D2B61CF9500F9D46B /* Resources in Resources */ = {isa = PBXBuildFile; fileRef = 3DF7B79528846FCC005DD8CA /* Resources */; };
284+
EAE1E1542B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = EAE1E1532B473B0C0048B157 /* PrivacyInfo.xcprivacy */; };
285+
EAE1E1552B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = EAE1E1532B473B0C0048B157 /* PrivacyInfo.xcprivacy */; };
286+
EAE1E1562B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = EAE1E1532B473B0C0048B157 /* PrivacyInfo.xcprivacy */; };
287+
EAE1E1572B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = EAE1E1532B473B0C0048B157 /* PrivacyInfo.xcprivacy */; };
288+
EAE1E1582B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = EAE1E1532B473B0C0048B157 /* PrivacyInfo.xcprivacy */; };
289+
EAE1E1592B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = EAE1E1532B473B0C0048B157 /* PrivacyInfo.xcprivacy */; };
290+
EAE1E15A2B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = EAE1E1532B473B0C0048B157 /* PrivacyInfo.xcprivacy */; };
284291
EE247AD71C3F04ED00AE3E12 /* SQLite.h in Headers */ = {isa = PBXBuildFile; fileRef = EE247AD61C3F04ED00AE3E12 /* SQLite.h */; settings = {ATTRIBUTES = (Public, ); }; };
285292
EE247ADE1C3F04ED00AE3E12 /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE247AD31C3F04ED00AE3E12 /* SQLite.framework */; };
286293
EE247B031C3F06E900AE3E12 /* Blob.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE247AEE1C3F06E900AE3E12 /* Blob.swift */; };
@@ -420,6 +427,7 @@
420427
DEB306E52B61CEF500F9D46B /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
421428
DEB307112B61CF9500F9D46B /* SQLiteTests visionOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SQLiteTests visionOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
422429
DEB307132B61D04500F9D46B /* SQLite visionOS.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = "SQLite visionOS.xctestplan"; path = "Tests/SQLite visionOS.xctestplan"; sourceTree = "<group>"; };
430+
EAE1E1532B473B0C0048B157 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
423431
EE247AD31C3F04ED00AE3E12 /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
424432
EE247AD61C3F04ED00AE3E12 /* SQLite.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SQLite.h; sourceTree = "<group>"; };
425433
EE247AD81C3F04ED00AE3E12 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -645,6 +653,7 @@
645653
EE247AF71C3F06E900AE3E12 /* Foundation.swift */,
646654
EE247AF81C3F06E900AE3E12 /* Helpers.swift */,
647655
EE247AD81C3F04ED00AE3E12 /* Info.plist */,
656+
EAE1E1532B473B0C0048B157 /* PrivacyInfo.xcprivacy */,
648657
EE247AED1C3F06E900AE3E12 /* Core */,
649658
EE247AF41C3F06E900AE3E12 /* Extensions */,
650659
EE247AF91C3F06E900AE3E12 /* Typed */,
@@ -1037,13 +1046,15 @@
10371046
isa = PBXResourcesBuildPhase;
10381047
buildActionMask = 2147483647;
10391048
files = (
1049+
EAE1E1582B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */,
10401050
);
10411051
runOnlyForDeploymentPostprocessing = 0;
10421052
};
10431053
03A65E611C6BB0F60062603F /* Resources */ = {
10441054
isa = PBXResourcesBuildPhase;
10451055
buildActionMask = 2147483647;
10461056
files = (
1057+
EAE1E1592B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */,
10471058
3DF7B79828846FED005DD8CA /* Resources in Resources */,
10481059
);
10491060
runOnlyForDeploymentPostprocessing = 0;
@@ -1052,6 +1063,7 @@
10521063
isa = PBXResourcesBuildPhase;
10531064
buildActionMask = 2147483647;
10541065
files = (
1066+
EAE1E15A2B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */,
10551067
);
10561068
runOnlyForDeploymentPostprocessing = 0;
10571069
};
@@ -1074,13 +1086,15 @@
10741086
isa = PBXResourcesBuildPhase;
10751087
buildActionMask = 2147483647;
10761088
files = (
1089+
EAE1E1542B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */,
10771090
);
10781091
runOnlyForDeploymentPostprocessing = 0;
10791092
};
10801093
EE247ADB1C3F04ED00AE3E12 /* Resources */ = {
10811094
isa = PBXResourcesBuildPhase;
10821095
buildActionMask = 2147483647;
10831096
files = (
1097+
EAE1E1552B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */,
10841098
3DF7B79628846FCC005DD8CA /* Resources in Resources */,
10851099
);
10861100
runOnlyForDeploymentPostprocessing = 0;
@@ -1089,13 +1103,15 @@
10891103
isa = PBXResourcesBuildPhase;
10901104
buildActionMask = 2147483647;
10911105
files = (
1106+
EAE1E1562B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */,
10921107
);
10931108
runOnlyForDeploymentPostprocessing = 0;
10941109
};
10951110
EE247B431C3F3ED000AE3E12 /* Resources */ = {
10961111
isa = PBXResourcesBuildPhase;
10971112
buildActionMask = 2147483647;
10981113
files = (
1114+
EAE1E1572B473B0C0048B157 /* PrivacyInfo.xcprivacy in Resources */,
10991115
3DF7B79928847055005DD8CA /* Resources in Resources */,
11001116
);
11011117
runOnlyForDeploymentPostprocessing = 0;

Sources/SQLite/Core/Value.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public protocol Value: Expressible { // extensions cannot have inheritance claus
3939

4040
static var declaredDatatype: String { get }
4141

42-
static func fromDatatypeValue(_ datatypeValue: Datatype) -> ValueType
42+
static func fromDatatypeValue(_ datatypeValue: Datatype) throws -> ValueType
4343

4444
var datatypeValue: Datatype { get }
4545

Sources/SQLite/Helpers.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ func transcode(_ literal: Binding?) -> String {
121121
}
122122
}
123123

124-
// swiftlint:disable force_cast
124+
// swiftlint:disable force_cast force_try
125125
func value<A: Value>(_ binding: Binding) -> A {
126-
A.fromDatatypeValue(binding as! A.Datatype) as! A
126+
try! A.fromDatatypeValue(binding as! A.Datatype) as! A
127127
}
128128

129129
func value<A: Value>(_ binding: Binding?) -> A {

Sources/SQLite/PrivacyInfo.xcprivacy

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSPrivacyTrackingDomains</key>
6+
<array/>
7+
<key>NSPrivacyCollectedDataTypes</key>
8+
<array/>
9+
<key>NSPrivacyAccessedAPITypes</key>
10+
<array/>
11+
<key>NSPrivacyTracking</key>
12+
<false/>
13+
</dict>
14+
</plist>

Sources/SQLite/Typed/Query.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ extension Connection {
10971097
public func scalar<V: Value>(_ query: ScalarQuery<V?>) throws -> V.ValueType? {
10981098
let expression = query.expression
10991099
guard let value = try scalar(expression.template, expression.bindings) as? V.Datatype else { return nil }
1100-
return V.fromDatatypeValue(value)
1100+
return try V.fromDatatypeValue(value)
11011101
}
11021102

11031103
public func scalar<V: Value>(_ query: Select<V>) throws -> V {
@@ -1108,7 +1108,7 @@ extension Connection {
11081108
public func scalar<V: Value>(_ query: Select<V?>) throws -> V.ValueType? {
11091109
let expression = query.expression
11101110
guard let value = try scalar(expression.template, expression.bindings) as? V.Datatype else { return nil }
1111-
return V.fromDatatypeValue(value)
1111+
return try V.fromDatatypeValue(value)
11121112
}
11131113

11141114
public func pluck(_ query: QueryType) throws -> Row? {
@@ -1200,9 +1200,9 @@ public struct Row {
12001200
}
12011201

12021202
public func get<V: Value>(_ column: Expression<V?>) throws -> V? {
1203-
func valueAtIndex(_ idx: Int) -> V? {
1203+
func valueAtIndex(_ idx: Int) throws -> V? {
12041204
guard let value = values[idx] as? V.Datatype else { return nil }
1205-
return V.fromDatatypeValue(value) as? V
1205+
return try V.fromDatatypeValue(value) as? V
12061206
}
12071207

12081208
guard let idx = columnNames[column.template] else {
@@ -1224,10 +1224,10 @@ public struct Row {
12241224
similar: columnNames.keys.filter(similar).sorted()
12251225
)
12261226
}
1227-
return valueAtIndex(columnNames[firstIndex].value)
1227+
return try valueAtIndex(columnNames[firstIndex].value)
12281228
}
12291229

1230-
return valueAtIndex(idx)
1230+
return try valueAtIndex(idx)
12311231
}
12321232

12331233
public subscript<T: Value>(column: Expression<T>) -> T {

Tests/SQLiteTests/Typed/RowTests.swift

+30
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,34 @@ class RowTests: XCTestCase {
8585
}
8686
}
8787
}
88+
89+
public func test_get_datatype_throws() {
90+
// swiftlint:disable nesting
91+
struct MyType: Value {
92+
enum MyError: Error {
93+
case failed
94+
}
95+
96+
public static var declaredDatatype: String {
97+
Blob.declaredDatatype
98+
}
99+
100+
public static func fromDatatypeValue(_ dataValue: Blob) throws -> Data {
101+
throw MyError.failed
102+
}
103+
104+
public var datatypeValue: Blob {
105+
return Blob(bytes: [])
106+
}
107+
}
108+
109+
let row = Row(["\"foo\"": 0], [Blob(bytes: [])])
110+
XCTAssertThrowsError(try row.get(Expression<MyType>("foo"))) { error in
111+
if case MyType.MyError.failed = error {
112+
XCTAssertTrue(true)
113+
} else {
114+
XCTFail("unexpected error: \(error)")
115+
}
116+
}
117+
}
88118
}

0 commit comments

Comments
 (0)