提交 5ed6d648 authored 作者: noelgrandin's avatar noelgrandin

fixes for Issue 528: Add Oracle-compatible TO_CHAR function

上级 7914d55a
......@@ -3351,7 +3351,7 @@ CALL XMLTEXT('test')
"
"Functions (String)","TO_CHAR","
TO_CHAR(value [, format[, nlsParam]])
TO_CHAR(value [, formatString[, nlsParamString]])
","
Oracle-compatible TO_CHAR function that can format a timestamp, a number, or text.
","
......
......@@ -1184,7 +1184,7 @@ XMLTEXT(valueString [, escapeNewlineBoolean])
","
Creates an XML text element."
"Functions (String)","TO_CHAR","
TO_CHAR(value [, format[, nlsParam]])
TO_CHAR(value [, formatString[, nlsParamString]])
","
Oracle-compatible TO_CHAR function that can format a timestamp, a number, or text."
"Functions (Time and Date)","CURRENT_DATE","
......
......@@ -208,7 +208,9 @@ public class ToChar {
output.insert(0, currency.getSymbol());
maxLength += 9;
} else if (c == '$') {
output.insert(0, c);
Currency currency = Currency.getInstance(Locale.getDefault());
String cs = currency.getSymbol();
output.insert(0, cs);
} else {
throw DbException.get(ErrorCode.INVALID_TO_CHAR_FORMAT, originalFormat);
}
......
......@@ -981,8 +981,8 @@ public abstract class TestBase {
try {
stat.executeQuery(sql);
fail("Expected error: " + expectedErrorMessage);
} catch (SQLException e) {
assertTrue(e.getMessage().startsWith(expectedErrorMessage));
} catch (SQLException ex) {
assertStartsWith(ex.getMessage(), expectedErrorMessage);
}
}
......
......@@ -1215,9 +1215,9 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult("1.23456789012345E+14", stat, "SELECT TO_CHAR(123456789012345, 'TME') FROM DUAL");
assertResult("4.5E-01", stat, "SELECT TO_CHAR(0.45, 'TME') FROM DUAL");
assertResult("4.5E-01", stat, "SELECT TO_CHAR(0.45, 'tMe') FROM DUAL");
assertThrows("Invalid format \"999.99q\"", stat, "SELECT TO_CHAR(123.45, '999.99q') FROM DUAL");
assertThrows("Invalid format \"fm999.99q\"", stat, "SELECT TO_CHAR(123.45, 'fm999.99q') FROM DUAL");
assertThrows("Invalid format \"q999.99\"", stat, "SELECT TO_CHAR(123.45, 'q999.99') FROM DUAL");
assertThrows("Invalid TO_CHAR format \"999.99q\"", stat, "SELECT TO_CHAR(123.45, '999.99q') FROM DUAL");
assertThrows("Invalid TO_CHAR format \"fm999.99q\"", stat, "SELECT TO_CHAR(123.45, 'fm999.99q') FROM DUAL");
assertThrows("Invalid TO_CHAR format \"q999.99\"", stat, "SELECT TO_CHAR(123.45, 'q999.99') FROM DUAL");
conn.close();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论