From a1d5530290373da956c927fc2ff76fbbdaa8e728 Mon Sep 17 00:00:00 2001 From: lvca Date: Wed, 8 Nov 2023 16:26:40 -0500 Subject: [PATCH] test: added test case to check for empty parameters in custom functions --- .../function/sql/SQLDefinedSQLFunctionTest.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/engine/src/test/java/com/arcadedb/function/sql/SQLDefinedSQLFunctionTest.java b/engine/src/test/java/com/arcadedb/function/sql/SQLDefinedSQLFunctionTest.java index c2ef4227ae..b36506c421 100644 --- a/engine/src/test/java/com/arcadedb/function/sql/SQLDefinedSQLFunctionTest.java +++ b/engine/src/test/java/com/arcadedb/function/sql/SQLDefinedSQLFunctionTest.java @@ -1,8 +1,10 @@ package com.arcadedb.function.sql; import com.arcadedb.TestHelper; +import com.arcadedb.exception.CommandSQLParsingException; import com.arcadedb.function.FunctionLibraryDefinition; import com.arcadedb.query.sql.executor.ResultSet; +import com.arcadedb.query.sql.parser.ParseException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -23,11 +25,21 @@ public void testCallFromSQLWithParams() { @Test public void testCallFromSQLNoParams() { - registerFunctions(); + database.command("sql", "define function math.hello \"select 'hello'\" language sql"); final ResultSet result = database.command("sql", "select `math.hello`() as result"); Assertions.assertEquals("hello", result.next().getProperty("result")); } + @Test + public void errorTestCallFromSQLEmptyParams() { + try { + database.command("sql", "define function math.hello \"select 'hello'\" parameters [] language sql"); + Assertions.fail(); + } catch (CommandSQLParsingException e) { + // EXPECTED + } + } + @Test public void testReuseSameQueryEngine() { registerFunctions(); @@ -69,7 +81,6 @@ public void testRedefineFunction() { private void registerFunctions() { database.command("sql", "define function math.sum \"select :a + :b;\" parameters [a,b] language sql"); database.command("sql", "define function util.sum \"select :a + :b;\" parameters [a,b] language sql"); - database.command("sql", "define function math.hello \"select 'hello'\" language sql"); final FunctionLibraryDefinition flib = database.getSchema().getFunctionLibrary("math"); Assertions.assertNotNull(flib);