提交 bbad6234 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Partially revert the previous commit

上级 61a0fcf6
...@@ -14,7 +14,6 @@ import java.lang.management.OperatingSystemMXBean; ...@@ -14,7 +14,6 @@ import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
...@@ -689,11 +688,6 @@ public class Utils { ...@@ -689,11 +688,6 @@ public class Utils {
return false; return false;
} }
} }
try {
return new BigDecimal(value).signum() != 0;
} catch (NumberFormatException e) {
// Nothing to do
}
if (throwException) { if (throwException) {
throw new IllegalArgumentException(value); throw new IllegalArgumentException(value);
} }
......
...@@ -31,7 +31,6 @@ import org.h2.util.DateTimeUtils; ...@@ -31,7 +31,6 @@ import org.h2.util.DateTimeUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils;
/** /**
* This is the base class for all value classes. * This is the base class for all value classes.
...@@ -1012,10 +1011,19 @@ public abstract class Value { ...@@ -1012,10 +1011,19 @@ public abstract class Value {
case NULL: case NULL:
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
case BOOLEAN: { case BOOLEAN: {
try { if (s.equalsIgnoreCase("true") ||
return ValueBoolean.get(Utils.parseBoolean(s, false, true)); s.equalsIgnoreCase("t") ||
} catch (IllegalArgumentException e) { s.equalsIgnoreCase("yes") ||
throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, s); s.equalsIgnoreCase("y")) {
return ValueBoolean.get(true);
} else if (s.equalsIgnoreCase("false") ||
s.equalsIgnoreCase("f") ||
s.equalsIgnoreCase("no") ||
s.equalsIgnoreCase("n")) {
return ValueBoolean.get(false);
} else {
// convert to a number, and if it is not 0 then it is true
return ValueBoolean.get(new BigDecimal(s).signum() != 0);
} }
} }
case BYTE: case BYTE:
......
...@@ -265,11 +265,6 @@ public class TestUtils extends TestBase { ...@@ -265,11 +265,6 @@ public class TestUtils extends TestBase {
testParseBooleanCheckTrue("true"); testParseBooleanCheckTrue("true");
testParseBooleanCheckTrue("True"); testParseBooleanCheckTrue("True");
testParseBooleanCheckTrue("TRUE"); testParseBooleanCheckTrue("TRUE");
// Test numbers
testParseBooleanCheckFalse("0.0");
testParseBooleanCheckFalse("-0.0");
testParseBooleanCheckTrue("0.1");
testParseBooleanCheckTrue("-0.1");
// Test other values // Test other values
assertFalse(Utils.parseBoolean("BAD", false, false)); assertFalse(Utils.parseBoolean("BAD", false, false));
assertTrue(Utils.parseBoolean("BAD", true, false)); assertTrue(Utils.parseBoolean("BAD", true, false));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论