8000 Merge pull request #27 from thoughtmanifest/numeric-conversion-support · kwark/postgres-async-driver@4423c9d · GitHub
[go: up one dir, main page]

Skip to content

Commit 4423c9d

Browse files
authored
Merge pull request alaisi#27 from thoughtmanifest/numeric-conversion-support
Support Numeric Conversion from Object to BigDecimal.
2 parents dc6b2c5 + bbd07d8 commit 4423c9d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public <TArray> TArray toArray(Class<TArray> arrayType, Oid oid, byte[] value) {
8484
case VARCHAR_ARRAY:
8585
return ArrayConversions.toArray(arrayType, oid, value, StringConversions::toString);
8686

87+
case NUMERIC_ARRAY:
8788
case FLOAT4_ARRAY:
8889
case FLOAT8_ARRAY:
8990
return ArrayConversions.toArray(arrayType, oid, value, NumericConversions::toBigDecimal);
@@ -176,6 +177,7 @@ public Object toObject(Oid oid, byte[] value) {
176177
case INT2: return toShort(oid, value);
177178
case INT4: return toInteger(oid, value);
178179
case INT8: return toLong(oid, value);
180+
case NUMERIC: // fallthrough
179181
case FLOAT4: // fallthrough
180182
case FLOAT8: return toBigDecimal(oid, value);
181183
case BYTEA: return toBytes(oid, value);
@@ -190,6 +192,7 @@ public Object toObject(Oid oid, byte[] value) {
190192
case INT2_ARRAY:
191193
case INT4_ARRAY:
192194
case INT8_ARRAY:
195+
case NUMERIC_ARRAY:
193196
case FLOAT4_ARRAY:
194197
case FLOAT8_ARRAY:
195198
case TEXT_ARRAY:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static Double toDouble(Oid oid, byte[] value) {
9595
case FLOAT8:
9696
return Double.valueOf(new String(value, UTF_8));
9797
default:
98-
throw new SqlException("Unsupported conversion " + oid.name() + " -> BigDecimal");
98+
throw new SqlException("Unsupported conversion " + oid.name() + " -> Double");
9999
}
100100
}
101101

0 commit comments

Comments
 (0)
0