@@ -26,13 +26,13 @@ class Statement {
2626
2727 init ( _ connection: Connection , _ SQL: String ) throws { self . connection = connection}
2828
29- public func bind( _ values: Binding ? ... ) -> Statement { return Statement ( connection , " " ) }
30- public func bind( _ values: [ Binding ? ] ) -> Statement { return Statement ( connection , " " ) }
31- public func bind( _ values: [ String : Binding ? ] ) -> Statement { return Statement ( connection , " " ) }
29+ public func bind( _ values: Binding ? ... ) -> Statement { return self }
30+ public func bind( _ values: [ Binding ? ] ) -> Statement { return self }
31+ public func bind( _ values: [ String : Binding ? ] ) -> Statement { return self }
3232
33- @discardableResult public func run( _ bindings: Binding ? ... ) throws -> Statement { return Statement ( connection , " " ) }
34- @discardableResult public func run( _ bindings: [ Binding ? ] ) throws -> Statement { return Statement ( connection , " " ) }
35- @discardableResult public func run( _ bindings: [ String : Binding ? ] ) throws -> Statement { return Statement ( connection , " " ) }
33+ @discardableResult public func run( _ bindings: Binding ? ... ) throws -> Statement { return self }
34+ @discardableResult public func run( _ bindings: [ Binding ? ] ) throws -> Statement { return self }
35+ @discardableResult public func run( _ bindings: [ String : Binding ? ] ) throws -> Statement { return self }
3636
3737 public func scalar( _ bindings: Binding ? ... ) throws -> Binding ? { return nil }
3838 public func scalar( _ bindings: [ Binding ? ] ) throws -> Binding ? { return nil }
@@ -42,13 +42,13 @@ class Statement {
4242class Connection {
4343 public func execute( _ SQL: String ) throws { }
4444
45- public func prepare( _ statement: String , _ bindings: Binding ? ... ) throws -> Statement { return Statement ( self , " " ) }
46- public func prepare( _ statement: String , _ bindings: [ Binding ? ] ) throws -> Statement { return Statement ( self , " " ) }
47- public func prepare( _ statement: String , _ bindings: [ String : Binding ? ] ) throws -> Statement { return Statement ( self , " " ) }
45+ public func prepare( _ statement: String , _ bindings: Binding ? ... ) throws -> Statement { return try Statement ( self , " " ) }
46+ public func prepare( _ statement: String , _ bindings: [ Binding ? ] ) throws -> Statement { return try Statement ( self , " " ) }
47+ public func prepare( _ statement: String , _ bindings: [ String : Binding ? ] ) throws -> Statement { return try Statement ( self , " " ) }
4848
49- @discardableResult public func run( _ statement: String , _ bindings: Binding ? ... ) throws -> Statement { return Statement ( self , " " ) }
50- @discardableResult public func run( _ statement: String , _ bindings: [ Binding ? ] ) throws -> Statement { return Statement ( self , " " ) }
51- @discardableResult public func run( _ statement: String , _ bindings: [ String : Binding ? ] ) throws -> Statement { return Statement ( self , " " ) }
49+ @discardableResult public func run( _ statement: String , _ bindings: Binding ? ... ) throws -> Statement { return try Statement ( self , " " ) }
50+ @discardableResult public func run( _ statement: String , _ bindings: [ Binding ? ] ) throws -> Statement { return try Statement ( self , " " ) }
51+ @discardableResult public func run( _ statement: String , _ bindings: [ String : Binding ? ] ) throws -> Statement { return try Statement ( self , " " ) }
5252
5353 public func scalar( _ statement: String , _ bindings: Binding ? ... ) throws -> Binding ? { return nil }
5454 public func scalar( _ statement: String , _ bindings: [ Binding ? ] ) throws -> Binding ? { return nil }
@@ -57,9 +57,9 @@ class Connection {
5757
5858// --- tests ---
5959
60- func test_sqlite_swift_api( db: Connection ) {
60+ func test_sqlite_swift_api( db: Connection ) throws {
6161 let localString = " user "
62- let remoteString = try ! String ( contentsOf: URL ( string: " http://example.com/ " ) !)
62+ let remoteString = try String ( contentsOf: URL ( string: " http://example.com/ " ) !)
6363 let remoteNumber = Int ( remoteString) ?? 0
6464
6565 let unsafeQuery1 = remoteString
@@ -89,11 +89,11 @@ func test_sqlite_swift_api(db: Connection) {
8989 let stmt3 = try db. prepare ( varQuery, remoteString) // GOOD
9090 try stmt3. run ( )
9191
92- let stmt4 = Statement ( db, localString) // GOOD
93- stmt4. run ( )
92+ let stmt4 = try Statement ( db, localString) // GOOD
93+ try stmt4. run ( )
9494
95- let stmt5 = Statement ( db, remoteString) // BAD
96- stmt5. run ( )
95+ let stmt5 = try Statement ( db, remoteString) // BAD
96+ try stmt5. run ( )
9797
9898 // --- more variants ---
9999
@@ -106,28 +106,28 @@ func test_sqlite_swift_api(db: Connection) {
106106 let stmt8 = try db. prepare ( unsafeQuery1, [ " username " : " " ] ) // BAD
107107 try stmt8. run ( )
108108
109- db. run ( unsafeQuery1, " " ) // BAD
109+ try db. run ( unsafeQuery1, " " ) // BAD
110110
111- db. run ( unsafeQuery1, [ " " ] ) // BAD
111+ try db. run ( unsafeQuery1, [ " " ] ) // BAD
112112
113- db. run ( unsafeQuery1, [ " username " : " " ] ) // BAD
113+ try db. run ( unsafeQuery1, [ " username " : " " ] ) // BAD
114114
115- db. scalar ( unsafeQuery1, " " ) // BAD
115+ try db. scalar ( unsafeQuery1, " " ) // BAD
116116
117- db. scalar ( unsafeQuery1, [ " " ] ) // BAD
117+ try db. scalar ( unsafeQuery1, [ " " ] ) // BAD
118118
119- db. scalar ( unsafeQuery1, [ " username " : " " ] ) // BAD
119+ try db. scalar ( unsafeQuery1, [ " username " : " " ] ) // BAD
120120
121121 let stmt9 = try db. prepare ( varQuery) // GOOD
122- stmt9. bind ( remoteString) // GOOD
123- stmt9. bind ( [ remoteString] ) // GOOD
124- stmt9. bind ( [ " username " : remoteString] ) // GOOD
122+ try stmt9. bind ( remoteString) // GOOD
123+ try stmt9. bind ( [ remoteString] ) // GOOD
124+ try stmt9. bind ( [ " username " : remoteString] ) // GOOD
125125 try stmt9. run ( remoteString) // GOOD
126126 try stmt9. run ( [ remoteString] ) // GOOD
127127 try stmt9. run ( [ " username " : remoteString] ) // GOOD
128128 try stmt9. scalar ( remoteString) // GOOD
129129 try stmt9. scalar ( [ remoteString] ) // GOOD
130130 try stmt9. scalar ( [ " username " : remoteString] ) // GOOD
131131
132- Statement ( db, remoteString) . run ( ) // BAD
132+ try Statement ( db, remoteString) . run ( ) // BAD
133133}
0 commit comments