@@ -13,7 +13,7 @@ import CSQLite
1313import SQLite3
1414#endif
1515
16- class CustomAggregationTests : SQLiteTestCase {
16+ class CustomAggregationTests : SQLiteTestCase {
1717 override func setUp( ) {
1818 super. setUp ( )
1919 createUsersTable ( )
@@ -35,7 +35,7 @@ class CustomAggregationTests : SQLiteTestCase {
3535 p. deallocate ( )
3636 return v
3737 }
38- let _ = db. createAggregation ( " mySUM1 " , step: step, final: final) {
38+ _ = db. createAggregation ( " mySUM1 " , step: step, final: final) {
3939 let v = UnsafeMutableBufferPointer< Int64> . allocate( capacity: 1 )
4040 v [ 0 ] = 0
4141 return v. baseAddress!
@@ -60,7 +60,7 @@ class CustomAggregationTests : SQLiteTestCase {
6060 p. deallocate ( )
6161 return v
6262 }
63- let _ = db. createAggregation ( " mySUM2 " , step: step, final: final) {
63+ _ = db. createAggregation ( " mySUM2 " , step: step, final: final) {
6464 let v = UnsafeMutableBufferPointer< Int64> . allocate( capacity: 1 )
6565 v [ 0 ] = 0
6666 return v. baseAddress!
@@ -72,11 +72,11 @@ class CustomAggregationTests : SQLiteTestCase {
7272 }
7373
7474 func testCustomSum( ) {
75- let reduce : ( Int64 , [ Binding ? ] ) -> Int64 = { ( last, bindings) in
75+ let reduce : ( Int64 , [ Binding ? ] ) -> Int64 = { ( last, bindings) in
7676 let v = ( bindings [ 0 ] as? Int64 ) ?? 0
7777 return last + v
7878 }
79- let _ = db. createAggregation ( " myReduceSUM1 " , initialValue: Int64 ( 2000 ) , reduce: reduce, result: { $0 } )
79+ _ = db. createAggregation ( " myReduceSUM1 " , initialValue: Int64 ( 2000 ) , reduce: reduce, result: { $0 } )
8080 let result = try ! db. prepare ( " SELECT myReduceSUM1(age) AS s FROM users " )
8181 let i = result. columnNames. firstIndex ( of: " s " ) !
8282 for row in result {
@@ -86,11 +86,11 @@ class CustomAggregationTests : SQLiteTestCase {
8686 }
8787
8888 func testCustomSumGrouping( ) {
89- let reduce : ( Int64 , [ Binding ? ] ) -> Int64 = { ( last, bindings) in
89+ let reduce : ( Int64 , [ Binding ? ] ) -> Int64 = { ( last, bindings) in
9090 let v = ( bindings [ 0 ] as? Int64 ) ?? 0
9191 return last + v
9292 }
93- let _ = db. createAggregation ( " myReduceSUM2 " , initialValue: Int64 ( 3000 ) , reduce: reduce, result: { $0 } )
93+ _ = db. createAggregation ( " myReduceSUM2 " , initialValue: Int64 ( 3000 ) , reduce: reduce, result: { $0 } )
9494 let result = try ! db. prepare ( " SELECT myReduceSUM2(age) AS s FROM users GROUP BY admin ORDER BY s " )
9595 let i = result. columnNames. firstIndex ( of: " s " ) !
9696 let values = result. compactMap { $0 [ i] as? Int64 }
@@ -99,11 +99,11 @@ class CustomAggregationTests : SQLiteTestCase {
9999
100100 func testCustomStringAgg( ) {
101101 let initial = String ( repeating: " " , count: 64 )
102- let reduce : ( String , [ Binding ? ] ) -> String = { ( last, bindings) in
102+ let reduce : ( String , [ Binding ? ] ) -> String = { ( last, bindings) in
103103 let v = ( bindings [ 0 ] as? String ) ?? " "
104104 return last + v
105105 }
106- let _ = db. createAggregation ( " myReduceSUM3 " , initialValue: initial, reduce: reduce, result: { $0 } )
106+ _ = db. createAggregation ( " myReduceSUM3 " , initialValue: initial, reduce: reduce, result: { $0 } )
107107 let result = try ! db. prepare ( " SELECT myReduceSUM3(email) AS s FROM users " )
108108 let i = result. columnNames. firstIndex ( of: " s " ) !
109109 for row in result {
@@ -115,14 +115,16 @@ class CustomAggregationTests : SQLiteTestCase {
115115 func testCustomObjectSum( ) {
116116 {
117117 let initial = TestObject ( value: 1000 )
118- let reduce : ( TestObject , [ Binding ? ] ) -> TestObject = { ( last, bindings) in
118+ let reduce : ( TestObject , [ Binding ? ] ) -> TestObject = { ( last, bindings) in
119119 let v = ( bindings [ 0 ] as? Int64 ) ?? 0
120120 return TestObject ( value: last. value + v)
121121 }
122- let _ = db. createAggregation ( " myReduceSUMX " , initialValue: initial, reduce: reduce, result: { $0. value } )
122+ db. createAggregation ( " myReduceSUMX " , initialValue: initial, reduce: reduce, result: { $0. value } )
123123 // end this scope to ensure that the initial value is retained
124124 // by the createAggregation call.
125+ // swiftlint:disable:next trailing_semicolon
125126 } ( ) ;
127+
126128 {
127129 XCTAssertEqual ( TestObject . inits, 1 )
128130 let result = try ! db. prepare ( " SELECT myReduceSUMX(age) AS s FROM users " )
0 commit comments