Skip to content

Commit 88d852f

Browse files
authored
Merge branch 'master' into vision-os
2 parents fec58b9 + fd14c44 commit 88d852f

File tree

14 files changed

+490
-20
lines changed

14 files changed

+490
-20
lines changed

Documentation/Index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
- [Other Operators](#other-operators)
6565
- [Core SQLite Functions](#core-sqlite-functions)
6666
- [Aggregate SQLite Functions](#aggregate-sqlite-functions)
67+
- [Window SQLite Functions](#window-sqlite-functions)
6768
- [Date and Time Functions](#date-and-time-functions)
6869
- [Custom SQL Functions](#custom-sql-functions)
6970
- [Custom Collations](#custom-collations)
@@ -1871,6 +1872,11 @@ Most of SQLite’s
18711872
[aggregate functions](https://www.sqlite.org/lang_aggfunc.html) have been
18721873
surfaced in and type-audited for SQLite.swift.
18731874

1875+
## Window SQLite Functions
1876+
1877+
Most of SQLite's [window functions](https://www.sqlite.org/windowfunctions.html) have been
1878+
surfaced in and type-audited for SQLite.swift. Currently only `OVER (ORDER BY ...)` windowing is possible.
1879+
18741880
## Date and Time functions
18751881

18761882
SQLite's [date and time](https://www.sqlite.org/lang_datefunc.html)

SQLite.xcodeproj/project.pbxproj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@
195195
49EB68C51F7B3CB400D89D40 /* Coding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49EB68C31F7B3CB400D89D40 /* Coding.swift */; };
196196
49EB68C61F7B3CB400D89D40 /* Coding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49EB68C31F7B3CB400D89D40 /* Coding.swift */; };
197197
49EB68C71F7B3CB400D89D40 /* Coding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49EB68C31F7B3CB400D89D40 /* Coding.swift */; };
198+
64A8EE432B095FBB00F583F7 /* WindowFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64A8EE422B095FBB00F583F7 /* WindowFunctions.swift */; };
199+
64A8EE442B095FBB00F583F7 /* WindowFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64A8EE422B095FBB00F583F7 /* WindowFunctions.swift */; };
200+
64A8EE452B095FBB00F583F7 /* WindowFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64A8EE422B095FBB00F583F7 /* WindowFunctions.swift */; };
201+
64A8EE462B095FBB00F583F7 /* WindowFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64A8EE422B095FBB00F583F7 /* WindowFunctions.swift */; };
202+
64B8E1702B09748000545AFB /* WindowFunctionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64B8E16F2B09748000545AFB /* WindowFunctionsTests.swift */; };
203+
64B8E1712B09748000545AFB /* WindowFunctionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64B8E16F2B09748000545AFB /* WindowFunctionsTests.swift */; };
204+
64B8E1722B09748000545AFB /* WindowFunctionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64B8E16F2B09748000545AFB /* WindowFunctionsTests.swift */; };
198205
997DF2AE287FC06D00F8DF95 /* Query+with.swift in Sources */ = {isa = PBXBuildFile; fileRef = 997DF2AD287FC06D00F8DF95 /* Query+with.swift */; };
199206
997DF2AF287FC06D00F8DF95 /* Query+with.swift in Sources */ = {isa = PBXBuildFile; fileRef = 997DF2AD287FC06D00F8DF95 /* Query+with.swift */; };
200207
997DF2B0287FC06D00F8DF95 /* Query+with.swift in Sources */ = {isa = PBXBuildFile; fileRef = 997DF2AD287FC06D00F8DF95 /* Query+with.swift */; };
@@ -281,6 +288,9 @@
281288
DEB307092B61CF9500F9D46B /* Connection+AttachTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A170C08525D3D27CB5F83C /* Connection+AttachTests.swift */; };
282289
DEB3070B2B61CF9500F9D46B /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03A65E5A1C6BB0F50062603F /* SQLite.framework */; };
283290
DEB3070D2B61CF9500F9D46B /* Resources in Resources */ = {isa = PBXBuildFile; fileRef = 3DF7B79528846FCC005DD8CA /* Resources */; };
291+
DBB93D5A2A22A373009BB96E /* SchemaReaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBB93D592A22A373009BB96E /* SchemaReaderTests.swift */; };
292+
DBB93D5B2A22A373009BB96E /* SchemaReaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBB93D592A22A373009BB96E /* SchemaReaderTests.swift */; };
293+
DBB93D5C2A22A373009BB96E /* SchemaReaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBB93D592A22A373009BB96E /* SchemaReaderTests.swift */; };
284294
EE247AD71C3F04ED00AE3E12 /* SQLite.h in Headers */ = {isa = PBXBuildFile; fileRef = EE247AD61C3F04ED00AE3E12 /* SQLite.h */; settings = {ATTRIBUTES = (Public, ); }; };
285295
EE247ADE1C3F04ED00AE3E12 /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE247AD31C3F04ED00AE3E12 /* SQLite.framework */; };
286296
EE247B031C3F06E900AE3E12 /* Blob.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE247AEE1C3F06E900AE3E12 /* Blob.swift */; };
@@ -412,6 +422,8 @@
412422
3DF7B79B2884C901005DD8CA /* Planning.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Planning.md; sourceTree = "<group>"; };
413423
3DFC0B862886C239001C8FC9 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
414424
49EB68C31F7B3CB400D89D40 /* Coding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Coding.swift; sourceTree = "<group>"; };
425+
64A8EE422B095FBB00F583F7 /* WindowFunctions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowFunctions.swift; sourceTree = "<group>"; };
426+
64B8E16F2B09748000545AFB /* WindowFunctionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowFunctionsTests.swift; sourceTree = "<group>"; };
415427
997DF2AD287FC06D00F8DF95 /* Query+with.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Query+with.swift"; sourceTree = "<group>"; };
416428
A121AC451CA35C79005A31D1 /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
417429
DB58B21028FB864300F8EEA4 /* SchemaReader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchemaReader.swift; sourceTree = "<group>"; };
@@ -420,6 +432,7 @@
420432
DEB306E52B61CEF500F9D46B /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
421433
DEB307112B61CF9500F9D46B /* SQLiteTests visionOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SQLiteTests visionOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
422434
DEB307132B61D04500F9D46B /* SQLite visionOS.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = "SQLite visionOS.xctestplan"; path = "Tests/SQLite visionOS.xctestplan"; sourceTree = "<group>"; };
435+
DBB93D592A22A373009BB96E /* SchemaReaderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchemaReaderTests.swift; sourceTree = "<group>"; };
423436
EE247AD31C3F04ED00AE3E12 /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
424437
EE247AD61C3F04ED00AE3E12 /* SQLite.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SQLite.h; sourceTree = "<group>"; };
425438
EE247AD81C3F04ED00AE3E12 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -572,13 +585,15 @@
572585
19A177EF5E2D91BA86DA4480 /* CustomAggregationTests.swift */,
573586
19A1709D5BDD2691BA160012 /* SetterTests.swift */,
574587
19A174FE5B47A97937A27276 /* RowTests.swift */,
588+
64B8E16F2B09748000545AFB /* WindowFunctionsTests.swift */,
575589
);
576590
path = Typed;
577591
sourceTree = "<group>";
578592
};
579593
19A17B56FBA20E7245BC8AC0 /* Schema */ = {
580594
isa = PBXGroup;
581595
children = (
596+
DBB93D592A22A373009BB96E /* SchemaReaderTests.swift */,
582597
19A176174862D0F0139B3987 /* SchemaDefinitionsTests.swift */,
583598
19A17FDB0B0CFB8987906FD0 /* SchemaChangerTests.swift */,
584599
19A17CA1DF7D0F7C9A94C51C /* Connection+SchemaTests.swift */,
@@ -706,6 +721,7 @@
706721
isa = PBXGroup;
707722
children = (
708723
EE247AFA1C3F06E900AE3E12 /* AggregateFunctions.swift */,
724+
64A8EE422B095FBB00F583F7 /* WindowFunctions.swift */,
709725
EE247AFB1C3F06E900AE3E12 /* Collation.swift */,
710726
EE247AFC1C3F06E900AE3E12 /* CoreFunctions.swift */,
711727
EE247AFD1C3F06E900AE3E12 /* CustomFunctions.swift */,
@@ -1120,6 +1136,7 @@
11201136
3DF7B78A28842972005DD8CA /* Connection+Attach.swift in Sources */,
11211137
03A65E811C6BB2FB0062603F /* CustomFunctions.swift in Sources */,
11221138
03A65E7A1C6BB2F70062603F /* Statement.swift in Sources */,
1139+
64A8EE452B095FBB00F583F7 /* WindowFunctions.swift in Sources */,
11231140
03A65E741C6BB2DA0062603F /* Helpers.swift in Sources */,
11241141
03A65E831C6BB2FB0062603F /* Operators.swift in Sources */,
11251142
03A65E851C6BB2FB0062603F /* Schema.swift in Sources */,
@@ -1158,6 +1175,7 @@
11581175
19A17FACE8E4D54A50BA934E /* FTS5Tests.swift in Sources */,
11591176
19A177909023B7B940C5805E /* FTSIntegrationTests.swift in Sources */,
11601177
19A17E1DD976D5CE80018749 /* FTS4Tests.swift in Sources */,
1178+
DBB93D5C2A22A373009BB96E /* SchemaReaderTests.swift in Sources */,
11611179
19A17411403D60640467209E /* ExpressionTests.swift in Sources */,
11621180
19A17CA4D7B63D845428A9C5 /* StatementTests.swift in Sources */,
11631181
19A17885B646CB0201BE4BD5 /* QueryTests.swift in Sources */,
@@ -1174,6 +1192,7 @@
11741192
19A17746150A815944A6820B /* SelectTests.swift in Sources */,
11751193
19A1766135CE9786B1878603 /* ValueTests.swift in Sources */,
11761194
19A177D5C6542E2D572162E5 /* QueryIntegrationTests.swift in Sources */,
1195+
64B8E1722B09748000545AFB /* WindowFunctionsTests.swift in Sources */,
11771196
19A178DF5A96CFEFF1E271F6 /* AggregateFunctionsTests.swift in Sources */,
11781197
19A17437659BD7FD787D94A6 /* CustomAggregationTests.swift in Sources */,
11791198
19A17F907258E524B3CA2FAE /* SetterTests.swift in Sources */,
@@ -1217,6 +1236,7 @@
12171236
19A17DC282E36C4F41AA440B /* Errors.swift in Sources */,
12181237
19A173668D948AD4DF1F5352 /* DateAndTimeFunctions.swift in Sources */,
12191238
19A17DF8D4F13A20F5D2269E /* Result.swift in Sources */,
1239+
64A8EE462B095FBB00F583F7 /* WindowFunctions.swift in Sources */,
12201240
19A17DFE05ED8B1F7C45F7EE /* SchemaChanger.swift in Sources */,
12211241
19A17D1BEABA610ABF003D67 /* SchemaDefinitions.swift in Sources */,
12221242
19A17A33EA026C2E2CEBAF36 /* Connection+Schema.swift in Sources */,
@@ -1321,6 +1341,7 @@
13211341
EE247B151C3F06E900AE3E12 /* Setter.swift in Sources */,
13221342
3DF7B78828842972005DD8CA /* Connection+Attach.swift in Sources */,
13231343
EE247B101C3F06E900AE3E12 /* CustomFunctions.swift in Sources */,
1344+
64A8EE432B095FBB00F583F7 /* WindowFunctions.swift in Sources */,
13241345
EE247B091C3F06E900AE3E12 /* FTS4.swift in Sources */,
13251346
EE247B081C3F06E900AE3E12 /* Value.swift in Sources */,
13261347
EE247B121C3F06E900AE3E12 /* Operators.swift in Sources */,
@@ -1359,6 +1380,7 @@
13591380
19A178DA2BB5970778CCAF13 /* FTS5Tests.swift in Sources */,
13601381
19A1755C49154C87304C9146 /* FTSIntegrationTests.swift in Sources */,
13611382
19A17444861E1443143DEB44 /* FTS4Tests.swift in Sources */,
1383+
DBB93D5A2A22A373009BB96E /* SchemaReaderTests.swift in Sources */,
13621384
19A17DD33C2E43DD6EE05A60 /* ExpressionTests.swift in Sources */,
13631385
19A17D6EC40BC35A5DC81BA8 /* StatementTests.swift in Sources */,
13641386
19A17E3F47DA087E2B76D087 /* QueryTests.swift in Sources */,
@@ -1375,6 +1397,7 @@
13751397
19A17F7977364EC8CD33C3C3 /* SelectTests.swift in Sources */,
13761398
19A17FD22EF43DF428DD93BA /* ValueTests.swift in Sources */,
13771399
19A177AA5922527BBDC77CF9 /* QueryIntegrationTests.swift in Sources */,
1400+
64B8E1702B09748000545AFB /* WindowFunctionsTests.swift in Sources */,
13781401
19A179786A6826D58A70F8BC /* AggregateFunctionsTests.swift in Sources */,
13791402
19A1793972BDDDB027C113BB /* CustomAggregationTests.swift in Sources */,
13801403
19A1773155AC2BF2CA86A473 /* SetterTests.swift in Sources */,
@@ -1401,6 +1424,7 @@
14011424
3DF7B78928842972005DD8CA /* Connection+Attach.swift in Sources */,
14021425
EE247B701C3F3FEC00AE3E12 /* CustomFunctions.swift in Sources */,
14031426
EE247B691C3F3FEC00AE3E12 /* Statement.swift in Sources */,
1427+
64A8EE442B095FBB00F583F7 /* WindowFunctions.swift in Sources */,
14041428
EE247B641C3F3FDB00AE3E12 /* Helpers.swift in Sources */,
14051429
EE247B721C3F3FEC00AE3E12 /* Operators.swift in Sources */,
14061430
EE247B741C3F3FEC00AE3E12 /* Schema.swift in Sources */,
@@ -1439,6 +1463,7 @@
14391463
19A1776BD5127DFDF847FF1F /* FTS5Tests.swift in Sources */,
14401464
19A173088B85A7E18E8582A7 /* FTSIntegrationTests.swift in Sources */,
14411465
19A178767223229E61C5066F /* FTS4Tests.swift in Sources */,
1466+
DBB93D5B2A22A373009BB96E /* SchemaReaderTests.swift in Sources */,
14421467
19A1781CBA8968ABD3E00877 /* ExpressionTests.swift in Sources */,
14431468
19A17923494236793893BF72 /* StatementTests.swift in Sources */,
14441469
19A17A52BF29D27C9AA229E7 /* QueryTests.swift in Sources */,
@@ -1455,6 +1480,7 @@
14551480
19A17DE1FCDB5695702AD24D /* SelectTests.swift in Sources */,
14561481
19A1726002D24C14F876C8FE /* ValueTests.swift in Sources */,
14571482
19A173389E53CB24DFA8CEDD /* QueryIntegrationTests.swift in Sources */,
1483+
64B8E1712B09748000545AFB /* WindowFunctionsTests.swift in Sources */,
14581484
19A170C56745F9D722A73D77 /* AggregateFunctionsTests.swift in Sources */,
14591485
19A1772EBE65173EDFB1AFCA /* CustomAggregationTests.swift in Sources */,
14601486
19A17E0ABA6C415F014CD51C /* SetterTests.swift in Sources */,

Sources/SQLite/Core/Value.swift

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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/Schema/SchemaDefinitions.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,19 @@ public struct ColumnDefinition: Equatable {
5757
}
5858

5959
init(_ string: String) {
60-
self = Affinity.allCases.first { $0.rawValue.lowercased() == string.lowercased() } ?? .TEXT
60+
let test = string.uppercased()
61+
// https://sqlite.org/datatype3.html#determination_of_column_affinity
62+
if test.contains("INT") { // Rule 1
63+
self = .INTEGER
64+
} else if ["CHAR", "CLOB", "TEXT"].first(where: {test.contains($0)}) != nil { // Rule 2
65+
self = .TEXT
66+
} else if string.contains("BLOB") { // Rule 3
67+
self = .BLOB
68+
} else if ["REAL", "FLOA", "DOUB"].first(where: {test.contains($0)}) != nil { // Rule 4
69+
self = .REAL
70+
} else { // Rule 5
71+
self = .NUMERIC
72+
}
6173
}
6274
}
6375

@@ -107,7 +119,7 @@ public struct ColumnDefinition: Equatable {
107119
public struct ForeignKey: Equatable {
108120
let table: String
109121
let column: String
110-
let primaryKey: String
122+
let primaryKey: String?
111123
let onUpdate: String?
112124
let onDelete: String?
113125
}
@@ -365,7 +377,7 @@ extension ColumnDefinition.ForeignKey {
365377
([
366378
"REFERENCES",
367379
table.quote(),
368-
"(\(primaryKey.quote()))",
380+
primaryKey.map { "(\($0.quote()))" },
369381
onUpdate.map { "ON UPDATE \($0)" },
370382
onDelete.map { "ON DELETE \($0)" }
371383
] as [String?]).compactMap { $0 }

Sources/SQLite/Schema/SchemaReader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private enum ForeignKeyListTable {
187187
static let seqColumn = Expression<Int64>("seq")
188188
static let tableColumn = Expression<String>("table")
189189
static let fromColumn = Expression<String>("from")
190-
static let toColumn = Expression<String>("to")
190+
static let toColumn = Expression<String?>("to") // when null, use primary key
191191
static let onUpdateColumn = Expression<String>("on_update")
192192
static let onDeleteColumn = Expression<String>("on_delete")
193193
static let matchColumn = Expression<String>("match")

Sources/SQLite/Typed/AggregateFunctions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ extension ExpressionType where UnderlyingType: Value, UnderlyingType.Datatype: N
166166
/// salary.average
167167
/// // avg("salary")
168168
///
169-
/// - Returns: A copy of the expression wrapped with the `min` aggregate
169+
/// - Returns: A copy of the expression wrapped with the `avg` aggregate
170170
/// function.
171171
public var average: Expression<Double?> {
172172
Function.avg.wrap(self)
@@ -179,7 +179,7 @@ extension ExpressionType where UnderlyingType: Value, UnderlyingType.Datatype: N
179179
/// salary.sum
180180
/// // sum("salary")
181181
///
182-
/// - Returns: A copy of the expression wrapped with the `min` aggregate
182+
/// - Returns: A copy of the expression wrapped with the `sum` aggregate
183183
/// function.
184184
public var sum: Expression<UnderlyingType?> {
185185
Function.sum.wrap(self)
@@ -192,7 +192,7 @@ extension ExpressionType where UnderlyingType: Value, UnderlyingType.Datatype: N
192192
/// salary.total
193193
/// // total("salary")
194194
///
195-
/// - Returns: A copy of the expression wrapped with the `min` aggregate
195+
/// - Returns: A copy of the expression wrapped with the `total` aggregate
196196
/// function.
197197
public var total: Expression<Double> {
198198
Function.total.wrap(self)

Sources/SQLite/Typed/Query.swift

Lines changed: 6 additions & 6 deletions
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 {

0 commit comments

Comments
 (0)