@@ -19,6 +19,8 @@ func TestDataTypeName(t *testing.T) {
1919 {oid .T_int2 , "INT2" },
2020 {oid .T_varchar , "VARCHAR" },
2121 {oid .T_text , "TEXT" },
22+ {oid .T_bit , "BIT" },
23+ {oid .T_varbit , "VARBIT" },
2224 {oid .T_bool , "BOOL" },
2325 {oid .T_numeric , "NUMERIC" },
2426 {oid .T_date , "DATE" },
@@ -47,6 +49,8 @@ func TestDataType(t *testing.T) {
4749 {oid .T_int2 , reflect .Int16 },
4850 {oid .T_varchar , reflect .String },
4951 {oid .T_text , reflect .String },
52+ {oid .T_bit , reflect .String },
53+ {oid .T_varbit , reflect .String },
5054 {oid .T_bool , reflect .Bool },
5155 {oid .T_date , reflect .Struct },
5256 {oid .T_time , reflect .Struct },
@@ -76,6 +80,8 @@ func TestDataTypeLength(t *testing.T) {
7680 {oid .T_varchar , 65535 , 9 , 5 , true },
7781 {oid .T_text , 65535 , - 1 , math .MaxInt64 , true },
7882 {oid .T_bytea , 65535 , - 1 , math .MaxInt64 , true },
83+ {oid .T_bit , 0 , 10 , 10 , true },
84+ {oid .T_varbit , 0 , 10 , 10 , true },
7985 }
8086
8187 for i , tt := range tts {
@@ -160,6 +166,20 @@ func TestRowsColumnTypes(t *testing.T) {
160166 DecimalSize : decimalSize {Precision : 0 , Scale : 0 , OK : false },
161167 ScanType : reflect .TypeOf (float64 (0 )),
162168 },
169+ {
170+ Name : "bit4" ,
171+ TypeName : "BIT" ,
172+ Length : length {Len : 4 , OK : true },
173+ DecimalSize : decimalSize {Precision : 0 , Scale : 0 , OK : false },
174+ ScanType : reflect .TypeOf ("" ),
175+ },
176+ {
177+ Name : "varbit10" ,
178+ TypeName : "VARBIT" ,
179+ Length : length {Len : 10 , OK : true },
180+ DecimalSize : decimalSize {Precision : 0 , Scale : 0 , OK : false },
181+ ScanType : reflect .TypeOf ("" ),
182+ },
163183 }
164184
165185 db := pqtest .MustDB (t )
@@ -169,7 +189,9 @@ func TestRowsColumnTypes(t *testing.T) {
169189 1 as a,
170190 text 'bar' as bar,
171191 1.28::numeric(9, 2) as dec,
172- 3.1415::float8 as f
192+ 3.1415::float8 as f,
193+ '1111'::bit(4) as bit4,
194+ '1111'::varbit(10) as varbit10
173195 ` )
174196 if err != nil {
175197 t .Fatal (err )
@@ -180,7 +202,7 @@ func TestRowsColumnTypes(t *testing.T) {
180202 if err != nil {
181203 t .Fatal (err )
182204 }
183- if len (columns ) != 4 {
205+ if len (columns ) != 6 {
184206 t .Errorf ("expected 4 columns found %d" , len (columns ))
185207 }
186208
0 commit comments