@@ -538,6 +538,26 @@ class PostgreSQLConnectionTests: XCTestCase {
538
538
print ( c)
539
539
}
540
540
}
541
+
542
+ // https://github.com/vapor/postgresql/pull/109
543
+ func testZeroNumeric( ) throws {
544
+ let conn = try PostgreSQLConnection . makeTest ( )
545
+ struct ZeroNumeric : PostgreSQLTable , Equatable {
546
+ static let sqlTableIdentifierString = " zeronumerictest "
547
+ var foo : Int
548
+ }
549
+
550
+ defer { try ? conn. drop ( table: ZeroNumeric . self) . ifExists ( ) . run ( ) . wait ( ) }
551
+ try conn. create ( table: ZeroNumeric . self) . column ( for: \ZeroNumeric . foo, type: . numeric) . run ( ) . wait ( )
552
+
553
+ let a = ZeroNumeric ( foo: 0 )
554
+ try conn. insert ( into: ZeroNumeric . self) . value ( a) . run ( ) . wait ( )
555
+ let fetch : [ ZeroNumeric ] = try conn. select ( ) . all ( ) . from ( ZeroNumeric . self) . all ( decoding: ZeroNumeric . self) . wait ( )
556
+ switch fetch. count {
557
+ case 1 : XCTAssertEqual ( fetch [ 0 ] . foo, 0 )
558
+ default : XCTFail ( " invalid row count " )
559
+ }
560
+ }
541
561
542
562
static var allTests = [
543
563
( " testBenchmark " , testBenchmark) ,
@@ -558,6 +578,7 @@ class PostgreSQLConnectionTests: XCTestCase {
558
578
( " testOrderBy " , testOrderBy) ,
559
579
( " testInvalidDate " , testInvalidDate) ,
560
580
( " testEmptyArray " , testEmptyArray) ,
581
+ ( " testZeroNumeric " , testZeroNumeric) ,
561
582
]
562
583
}
563
584
0 commit comments