diff --git a/src/adql/db/FunctionDef.java b/src/adql/db/FunctionDef.java index 4a3d1f6ddd18d7dd6683ae77696ff5affe776a0d..645ede93a1cc12295998ab20c3b79183b9a6d573 100644 --- a/src/adql/db/FunctionDef.java +++ b/src/adql/db/FunctionDef.java @@ -289,6 +289,10 @@ public class FunctionDef implements Comparable<FunctionDef> { * @param returnType Return type of the function. * <i>If NULL, this function will have no return * type.</i> + * + * @throws ParseException If the given UDF name is invalid according to + * the {@link ADQLParserFactory#DEFAULT_VERSION default version} + * of the ADQL grammar. */ public FunctionDef(final String fctName, final DBType returnType) throws ParseException { this(fctName, returnType, null, null); diff --git a/src/adql/query/operand/function/DefaultUDF.java b/src/adql/query/operand/function/DefaultUDF.java index 326f5b899796e6f76d8cbb20b7b1ed50ce2e746b..aebb56480923a2fc63630c964938529cf79a6a00 100644 --- a/src/adql/query/operand/function/DefaultUDF.java +++ b/src/adql/query/operand/function/DefaultUDF.java @@ -239,7 +239,7 @@ public final class DefaultUDF extends UserDefinedFunction { } @Override - public String translate(final ADQLTranslator caller) throws TranslationException{ + public String translate(final ADQLTranslator caller) throws TranslationException { // Use the translation pattern if any is specified: if (definition != null && definition.getTranslationPattern() != null) { StringBuffer sql = new StringBuffer(); @@ -277,12 +277,12 @@ public final class DefaultUDF extends UserDefinedFunction { } // Otherwise, no translation needed (use the ADQL as translation result): else { - StringBuffer sql = new StringBuffer(functionName); - sql.append('('); - for(int i = 0; i < parameters.size(); i++){ - if (i > 0) - sql.append(',').append(' '); - sql.append(caller.translate(parameters.get(i))); + StringBuffer sql = new StringBuffer(functionName); + sql.append('('); + for(int i = 0; i < parameters.size(); i++) { + if (i > 0) + sql.append(',').append(' '); + sql.append(caller.translate(parameters.get(i))); } sql.append(')'); return sql.toString(); diff --git a/test/adql/db/TestFunctionDef.java b/test/adql/db/TestFunctionDef.java index 92bbfc003b1971965b8d16eedc473f2f38cf688e..e0fe91b79024ee7c6f41edbdbd5d549d96211fcf 100644 --- a/test/adql/db/TestFunctionDef.java +++ b/test/adql/db/TestFunctionDef.java @@ -2,6 +2,7 @@ package adql.db; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; diff --git a/test/adql/translator/TestJDBCTranslator.java b/test/adql/translator/TestJDBCTranslator.java index 3d8750e81b2d1e8649972f23374a1a9589a04134..c83dc5641c0fed47bea954443a84bf05b2207d74 100644 --- a/test/adql/translator/TestJDBCTranslator.java +++ b/test/adql/translator/TestJDBCTranslator.java @@ -41,7 +41,8 @@ public class TestJDBCTranslator { /* Ensure the translation from ADQL to SQL of strings is correct ; * particularly, ' should be escaped otherwise it would mean the end of a string in SQL *(the way to escape a such character is by doubling the character '): */ - try { + try{ +==== BASE ==== assertEquals("'SQL''s translation'", tr.translate(new StringConstant("SQL's translation"))); } catch(TranslationException e) { e.printStackTrace(System.err);