@@ -555,6 +555,19 @@ final class PostgresNIOTests: XCTestCase {
555555 let row = rows? . first? . makeRandomAccess ( )
556556 XCTAssertEqual ( row ? [ data: " array " ] . array ( of: Int . self) , [ ] )
557557 }
558+
559+ func testOptionalIntegerArrayParse( ) {
560+ var conn : PostgresConnection ?
561+ XCTAssertNoThrow ( conn = try PostgresConnection . test ( on: eventLoop) . wait ( ) )
562+ defer { XCTAssertNoThrow ( try conn? . close ( ) . wait ( ) ) }
563+ var rows : PostgresQueryResult ?
564+ XCTAssertNoThrow ( rows = try conn? . query ( """
565+ select
566+ '{1, 2, NULL, 4}'::int8[] as array
567+ """ ) . wait ( ) )
568+ let row = rows? . first? . makeRandomAccess ( )
569+ XCTAssertEqual ( row ? [ data: " array " ] . array ( of: Int ? . self) , [ 1 , 2 , nil , 4 ] )
570+ }
558571
559572 func testNullIntegerArrayParse( ) {
560573 var conn : PostgresConnection ?
@@ -599,6 +612,22 @@ final class PostgresNIOTests: XCTestCase {
599612 XCTAssertEqual ( row ? [ data: " array " ] . array ( of: Int . self) , [ ] )
600613 }
601614
615+ func testOptionalIntegerArraySerialize( ) {
616+ var conn : PostgresConnection ?
617+ XCTAssertNoThrow ( conn = try PostgresConnection . test ( on: eventLoop) . wait ( ) )
618+ defer { XCTAssertNoThrow ( try conn? . close ( ) . wait ( ) ) }
619+ var rows : PostgresQueryResult ?
620+ XCTAssertNoThrow ( rows = try conn? . query ( """
621+ select
622+ $1::int8[] as array
623+ """ , [
624+ PostgresData ( array: [ 1 , nil , 3 ] as [ Int64 ? ] )
625+ ] ) . wait ( ) )
626+ XCTAssertEqual ( rows? . count, 1 )
627+ let row = rows? . first? . makeRandomAccess ( )
628+ XCTAssertEqual ( row ? [ data: " array " ] . array ( of: Int64 ? . self) , [ 1 , nil , 3 ] )
629+ }
630+
602631 // https://github.com/vapor/postgres-nio/issues/143
603632 func testEmptyStringFromNonNullColumn( ) {
604633 var conn : PostgresConnection ?
0 commit comments