File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -268,16 +268,10 @@ private extension Collection {
268
268
// splits the collection into chunks of the supplied size
269
269
// if the collection is not evenly divisible, the first chunk will be smaller
270
270
func reverseChunked( by maxSize: Int ) -> [ SubSequence ] {
271
- var lastDistance = 0
272
271
var chunkStartIndex = self . startIndex
273
272
return stride ( from: 0 , to: self . count, by: maxSize) . reversed ( ) . map { current in
274
- let distance = ( self . count - current) - lastDistance
275
- lastDistance = distance
276
- let chunkEndOffset = Swift . min (
277
- self . distance ( from: chunkStartIndex, to: self . endIndex) ,
278
- distance
279
- )
280
- let chunkEndIndex = self . index ( chunkStartIndex, offsetBy: chunkEndOffset)
273
+ let distance = self . count - current
274
+ let chunkEndIndex = self . index ( self . startIndex, offsetBy: distance)
281
275
defer { chunkStartIndex = chunkEndIndex }
282
276
return self [ chunkStartIndex..< chunkEndIndex]
283
277
}
Original file line number Diff line number Diff line change @@ -617,21 +617,25 @@ final class PostgresNIOTests: XCTestCase {
617
617
let a = PostgresNumeric ( string: " 123456.789123 " ) !
618
618
let b = PostgresNumeric ( string: " -123456.789123 " ) !
619
619
let c = PostgresNumeric ( string: " 3.14159265358979 " ) !
620
+ let d = PostgresNumeric ( string: " 1234567898765 " ) !
620
621
var rows : PostgresQueryResult ?
621
622
XCTAssertNoThrow ( rows = try conn? . query ( """
622
623
select
623
624
$1::numeric as a,
624
625
$2::numeric as b,
625
- $3::numeric as c
626
+ $3::numeric as c,
627
+ $4::numeric as d
626
628
""" , [
627
629
. init( numeric: a) ,
628
630
. init( numeric: b) ,
629
- . init( numeric: c)
631
+ . init( numeric: c) ,
632
+ . init( numeric: d)
630
633
] ) . wait ( ) )
631
634
let row = rows? . first? . makeRandomAccess ( )
632
635
XCTAssertEqual ( row ? [ data: " a " ] . decimal, Decimal ( string: " 123456.789123 " ) !)
633
636
XCTAssertEqual ( row ? [ data: " b " ] . decimal, Decimal ( string: " -123456.789123 " ) !)
634
637
XCTAssertEqual ( row ? [ data: " c " ] . decimal, Decimal ( string: " 3.14159265358979 " ) !)
638
+ XCTAssertEqual ( row ? [ data: " d " ] . decimal, Decimal ( string: " 1234567898765 " ) !)
635
639
}
636
640
637
641
func testDecimalStringSerialization( ) {
You can’t perform that action at this time.
0 commit comments