[#8456] Calling Record.get(0, int.class) returns null if value is not convertible to int
This commit is contained in:
parent
859a8da297
commit
3a6ea32896
@ -44,6 +44,7 @@ import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD_3_0;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES_9_5;
|
||||
// ...
|
||||
// ...
|
||||
|
||||
@ -43,6 +43,7 @@ import static org.jooq.SQLDialect.CUBRID;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
|
||||
@ -43,6 +43,7 @@ import static org.jooq.SQLDialect.CUBRID;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
|
||||
@ -203,9 +203,8 @@ final class LoaderImpl<R extends Record> implements
|
||||
|
||||
@Override
|
||||
public final LoaderImpl<R> onDuplicateKeyUpdate() {
|
||||
if (table.getPrimaryKey() == null) {
|
||||
if (table.getPrimaryKey() == null)
|
||||
throw new IllegalStateException("ON DUPLICATE KEY UPDATE only works on tables with explicit primary keys. Table is not updatable : " + table);
|
||||
}
|
||||
|
||||
onDuplicate = ON_DUPLICATE_KEY_UPDATE;
|
||||
return this;
|
||||
|
||||
@ -88,6 +88,7 @@ import org.jooq.SQLDialect;
|
||||
import org.jooq.UDTRecord;
|
||||
import org.jooq.exception.DataTypeException;
|
||||
import org.jooq.tools.jdbc.MockArray;
|
||||
import org.jooq.tools.reflect.Reflect;
|
||||
import org.jooq.types.UByte;
|
||||
import org.jooq.types.UInteger;
|
||||
import org.jooq.types.ULong;
|
||||
@ -582,7 +583,7 @@ public final class Convert {
|
||||
return (U) Byte.valueOf(new BigDecimal(from.toString().trim()).byteValue());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return null;
|
||||
return Reflect.initValue(toClass);
|
||||
}
|
||||
}
|
||||
else if (wrapperTo == Short.class) {
|
||||
@ -596,7 +597,7 @@ public final class Convert {
|
||||
return (U) Short.valueOf(new BigDecimal(from.toString().trim()).shortValue());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return null;
|
||||
return Reflect.initValue(toClass);
|
||||
}
|
||||
}
|
||||
else if (wrapperTo == Integer.class) {
|
||||
@ -610,7 +611,7 @@ public final class Convert {
|
||||
return (U) Integer.valueOf(new BigDecimal(from.toString().trim()).intValue());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return null;
|
||||
return Reflect.initValue(toClass);
|
||||
}
|
||||
}
|
||||
else if (wrapperTo == Long.class) {
|
||||
@ -634,7 +635,7 @@ public final class Convert {
|
||||
return (U) Long.valueOf(new BigDecimal(from.toString().trim()).longValue());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return null;
|
||||
return Reflect.initValue(toClass);
|
||||
}
|
||||
}
|
||||
|
||||
@ -713,7 +714,7 @@ public final class Convert {
|
||||
return (U) Float.valueOf(from.toString().trim());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return null;
|
||||
return Reflect.initValue(toClass);
|
||||
}
|
||||
}
|
||||
else if (wrapperTo == Double.class) {
|
||||
@ -727,7 +728,7 @@ public final class Convert {
|
||||
return (U) Double.valueOf(from.toString().trim());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return null;
|
||||
return Reflect.initValue(toClass);
|
||||
}
|
||||
}
|
||||
else if (toClass == BigDecimal.class) {
|
||||
@ -767,7 +768,7 @@ public final class Convert {
|
||||
return (U) (((Boolean) from) ? Character.valueOf('1') : Character.valueOf('0'));
|
||||
|
||||
if (from.toString().length() < 1)
|
||||
return null;
|
||||
return Reflect.initValue(toClass);
|
||||
|
||||
return (U) Character.valueOf(from.toString().charAt(0));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user