File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change 11extension PostgresData {
22 public init ( int value: Int ) {
3- assert ( Int . bitWidth == 64 )
4- self . init ( type: . int8, value: . init( integer: value) )
3+ self . init ( type: . int8, value: . init( integer: Int64 ( value) ) )
54 }
65
76 public init ( uint8 value: UInt8 ) {
@@ -32,25 +31,19 @@ extension PostgresData {
3231 guard value. readableBytes == 1 else {
3332 return nil
3433 }
35- return value. readInteger ( as: UInt8 . self)
36- . flatMap ( Int . init)
34+ return value. readInteger ( as: UInt8 . self) . flatMap ( Int . init)
3735 case . int2:
3836 assert ( value. readableBytes == 2 )
39- return value. readInteger ( as: Int16 . self)
40- . flatMap ( Int . init)
37+ return value. readInteger ( as: Int16 . self) . flatMap ( Int . init)
4138 case . int4, . regproc:
4239 assert ( value. readableBytes == 4 )
43- return value. readInteger ( as: Int32 . self)
44- . flatMap ( Int . init)
40+ return value. readInteger ( as: Int32 . self) . flatMap ( Int . init)
4541 case . oid:
4642 assert ( value. readableBytes == 4 )
47- assert ( Int . bitWidth == 64 ) // or else overflow is possible
48- return value. readInteger ( as: UInt32 . self)
49- . flatMap ( Int . init)
43+ return value. readInteger ( as: UInt32 . self) . flatMap { Int ( exactly: $0) }
5044 case . int8:
5145 assert ( value. readableBytes == 8 )
52- assert ( Int . bitWidth == 64 )
53- return value. readInteger ( as: Int . self)
46+ return value. readInteger ( as: Int64 . self) . flatMap { Int ( exactly: $0) }
5447 default :
5548 return nil
5649 }
You can’t perform that action at this time.
0 commit comments