File tree 2 files changed +33
-28
lines changed
2 files changed +33
-28
lines changed Original file line number Diff line number Diff line change
1
+ // The MIT License (MIT)
2
+ //
3
+ // Copyright (c) 2020 Alexander Grebenyuk (github.com/kean).
4
+
5
+ import Foundation
6
+ import SQLite3
7
+
8
+ /// Represents a single row returned by the SQL statement.
9
+ public struct SQLRow {
10
+ let statement : SQLStatement // Storing as strong reference doesn't seem to affect performance
11
+ var ref : OpaquePointer { statement. ref }
12
+
13
+ #warning("TODO: document")
14
+ public subscript< T: SQLDataType > ( index: Int ) -> T {
15
+ T . sqlColumn ( statement: ref, index: Int32 ( index) )
16
+ }
17
+
18
+ public subscript< T: SQLDataType > ( index: Int ) -> T ? {
19
+ if sqlite3_column_type ( ref, Int32 ( index) ) == SQLITE_NULL {
20
+ return nil
21
+ } else {
22
+ return T . sqlColumn ( statement: ref, index: Int32 ( index) )
23
+ }
24
+ }
25
+
26
+ public subscript< T: SQLDataType > ( name: String ) -> T {
27
+ fatalError ( )
28
+ }
29
+
30
+ public subscript< T: SQLDataType > ( name: String ) -> T ? {
31
+ fatalError ( )
32
+ }
33
+ }
Original file line number Diff line number Diff line change @@ -221,31 +221,3 @@ public final class SQLStatement {
221
221
throw error
222
222
}
223
223
}
224
-
225
- #warning("TODO: is retaining statement fine in terms of performance?")
226
- public struct SQLRow {
227
- let statement : SQLStatement // Storing as strong reference doesn't seem to affect performance
228
- var ref : OpaquePointer { statement. ref }
229
-
230
- #warning("TODO: document")
231
- #warning("TODO: add null checks")
232
- public subscript< T: SQLDataType > ( index: Int ) -> T {
233
- T . sqlColumn ( statement: ref, index: Int32 ( index) )
234
- }
235
-
236
- public subscript< T: SQLDataType > ( index: Int ) -> T ? {
237
- if sqlite3_column_type ( ref, Int32 ( index) ) == SQLITE_NULL {
238
- return nil
239
- } else {
240
- return T . sqlColumn ( statement: ref, index: Int32 ( index) )
241
- }
242
- }
243
-
244
- public subscript< T: SQLDataType > ( name: String ) -> T {
245
- fatalError ( )
246
- }
247
-
248
- public subscript< T: SQLDataType > ( name: String ) -> T ? {
249
- fatalError ( )
250
- }
251
- }
You can’t perform that action at this time.
0 commit comments