File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,12 @@ private extension PostgresData {
115115 switch self . formatCode {
116116 case . binary:
117117 switch self . type {
118+ case . char, . bpchar:
119+ assert ( value. readableBytes == 1 )
120+ guard let uint8 = value. getInteger ( at: value. readerIndex, as: UInt8 . self) else {
121+ return nil
122+ }
123+ return I ( uint8)
118124 case . int2:
119125 assert ( value. readableBytes == 2 )
120126 guard let int16 = value. readInteger ( as: Int16 . self) else {
Original file line number Diff line number Diff line change @@ -979,6 +979,19 @@ final class PostgresNIOTests: XCTestCase {
979979 XCTAssertEqual ( rows [ 0 ] . column ( " doubles " ) ? . array ( of: Double . self) , doubles)
980980 }
981981
982+ // https://github.com/vapor/postgres-nio/issues/42
983+ func testUInt8Serialization( ) throws {
984+ let conn = try PostgresConnection . test ( on: eventLoop) . wait ( )
985+ defer { try ! conn. close ( ) . wait ( ) }
986+ let rows = try conn. query ( """
987+ select
988+ $1::char as int
989+ """ , [
990+ . init( uint8: 5 )
991+ ] ) . wait ( )
992+ XCTAssertEqual ( rows [ 0 ] . column ( " int " ) ? . uint8, 5 )
993+ }
994+
982995}
983996
984997
You can’t perform that action at this time.
0 commit comments