8000 Fixes #23: Add missing BOOL oid to types converted by default. · kwark/postgres-async-driver@832d8ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 832d8ef

Browse files
committed
Fixes alaisi#23: Add missing BOOL oid to types converted by default.
1 parent d5ed149 commit 832d8ef

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/java/com/github/pgasync/impl/conversion/DataConverter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public Object toObject(Oid oid, byte[] value) {
185185
case TIMESTAMP: // fallthrough
186186
case TIMESTAMPTZ: return toTimestamp(oid, value);
187187
case UUID: return UUID.fromString(toString(oid, value));
188+
case BOOL: return toBoolean(oid, value);
188189

189190
case INT2_ARRAY:
190191
case INT4_ARRAY:
@@ -199,6 +200,7 @@ public Object toObject(Oid oid, byte[] value) {
199200
case TIMESTAMPTZ_ARRAY:
200201
case TIMETZ_ARRAY:
201202
case TIME_ARRAY:
203+
case BOOL_ARRAY:
202204
return toArray(Object[].class, oid, value);
203205
default:
204206
return toConvertable(oid, value);

src/test/java/com/github/pgasync/impl/PreparedStatementTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.github.pgasync.impl;
1616

17+
import com.github.pgasync.ResultSet;
1718
import org.junit.AfterClass;
1819
import org.junit.BeforeClass;
1920
import org.junit.ClassRule;
@@ -22,12 +23,15 @@
2223
import java.sql.Date;
2324
import java.sql.Time;
2425
import java.text.SimpleDateFormat;
26+
import java.util.Collections;
2527
import java.util.TimeZone;
2628

2729
import static com.github.pgasync.impl.io.IO.bytes;
2830
import static java.util.Arrays.asList;
31+
import static java.util.Collections.singletonList;
2932
import static org.junit.Assert.assertArrayEquals;
3033
import static org.junit.Assert.assertEquals;
34+
import static org.junit.Assert.assertTrue;
3135

3236
/**
3337
* Tests for parameter binding.
@@ -46,7 +50,7 @@ public static void create() {
4650
+ "LONG INT8,INT INT4,SHORT INT2, BYTE INT2,"
4751
+ "CHAR CHAR(1), STRING VARCHAR(255), CLOB TEXT,"
4852
+ "TIME TIME, DATE DATE, TS TIMESTAMP,"
49-
+ "BYTEA BYTEA" + ")");
53+
+ "BYTEA BYTEA, BOOLEAN BOOLEAN)");
5054
}
5155

5256
@AfterClass
@@ -129,6 +133,14 @@ public void shouldBindBytes() throws Exception {
129133
assertArrayEquals(b, dbr.query("SELECT BYTEA FROM PS_TEST WHERE BYTEA = $1", asList(b)).row(0).getBytes(0));
130134
}
131135

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+
132144
static SimpleDateFormat dateFormat(String pattern) {
133145
SimpleDateFormat format = new SimpleDateFormat(pattern);
134146
format.setTimeZone(TimeZone.getTimeZone("UTC"));

0 commit comments

Comments
 (0)
0