[jOOQ/jOOQ#10880] Add DECFLOAT support

This includes:

- Support casts
- Support DDL
- Support MULTISET usage
- Support Db2's NAN (all uppercase) syntax
This commit is contained in:
Lukas Eder 2024-08-14 14:47:05 +02:00
parent 4bdc6f4a54
commit 0b7a5f3fc9
2 changed files with 22 additions and 12 deletions

View File

@ -188,28 +188,27 @@ public final class Decfloat extends Number implements Data {
if (coefficient != null || special != null)
return;
switch (data) {
case "+NaN":
case "NaN":
String lc;
switch (lc = data.toLowerCase()) {
case "+nan":
case "nan":
special = Special.NAN;
break;
case "+Infinity":
case "Infinity":
case "+Inf":
case "Inf":
case "+infinity":
case "infinity":
case "+inf":
case "inf":
special = Special.POSITIVE_INFINITY;
break;
case "-Infinity":
case "-Inf":
case "-infinity":
case "-inf":
special = Special.NEGATIVE_INFINITY;
break;
default: {
int i = data.indexOf("E");
if (i == -1)
i = data.indexOf("e");
int i = lc.indexOf("e");
try {
if (i == -1) {

View File

@ -593,6 +593,17 @@ final class Multiset<R extends Record> extends AbstractField<Result<R>> implemen
@SuppressWarnings("unchecked")
static final Field<?> castForJSON(Context<?> ctx, Field<?> field) {
DataType<?> t = field.getDataType();
// [#10880] Many dialects don't support NaN and other float values in JSON documents as numbers
if (t.isDecimal() && t.isFloat()) {
switch (ctx.family()) {
case H2:
return field.cast(VARCHAR);
}
}