14
14
15
15
package com .github .pgasync .impl ;
16
16
17
+ import com .github .pgasync .ResultSet ;
17
18
import org .junit .AfterClass ;
18
19
import org .junit .BeforeClass ;
19
20
import org .junit .ClassRule ;
22
23
import java .sql .Date ;
23
24
import java .sql .Time ;
24
25
import java .text .SimpleDateFormat ;
26
+ import java .util .Collections ;
25
27
import java .util .TimeZone ;
26
28
27
29
import static com .github .pgasync .impl .io .IO .bytes ;
28
30
import static java .util .Arrays .asList ;
31
+ import static java .util .Collections .singletonList ;
29
32
import static org .junit .Assert .assertArrayEquals ;
30
33
import static org .junit .Assert .assertEquals ;
34
+ import static org .junit .Assert .assertTrue ;
31
35
32
36
/**
33
37
* Tests for parameter binding.
@@ -46,7 +50,7 @@ public static void create() {
46
50
+ "LONG INT8,INT INT4,SHORT INT2, BYTE INT2,"
47
51
+ "CHAR CHAR(1), STRING VARCHAR(255), CLOB TEXT,"
48
52
+ "TIME TIME, DATE DATE, TS TIMESTAMP,"
49
- + "BYTEA BYTEA" + " )" );
53
+ + "BYTEA BYTEA, BOOLEAN BOOLEAN )" );
50
54
}
51
55
52
56
@ AfterClass
@@ -129,6 +133,14 @@ public void shouldBindBytes() throws Exception {
129
133
assertArrayEquals (b , dbr .query ("SELECT BYTEA FROM PS_TEST WHERE BYTEA = $1" , asList (b )).row (0 ).getBytes (0 ));
130
134
}
131
135
136
+ @ Test
137
+ public void shouldBindBoolean () throws Exception {
138
+ dbr .query ("INSERT INTO PS_TEST(BOOLEAN) VALUES ($1)" , singletonList (true ));
139
+ assertTrue ((Boolean ) ((PgRow ) dbr .query ("SELECT BOOLEAN FROM PS_TEST WHERE BOOLEAN = $1" ,
140
+ singletonList (true )).row (0 )).get ("BOOLEAN" ));
141
+
142
+ }
143
+
132
144
static SimpleDateFormat dateFormat (String pattern ) {
133
145
SimpleDateFormat format = new SimpleDateFormat (pattern );
134
146
format .setTimeZone (TimeZone .getTimeZone ("UTC" ));
0 commit comments