1818 */
1919package com .arcadedb .e2e ;
2020
21- import com .arcadedb .function .FunctionDefinition ;
2221import com .arcadedb .query .sql .executor .ResultSet ;
2322import com .arcadedb .remote .RemoteDatabase ;
2423import org .junit .jupiter .api .AfterEach ;
@@ -35,16 +34,27 @@ void setUp() {
3534 database = new RemoteDatabase (host , httpPort , "beer" , "root" , "playwithdata" );
3635 // ENLARGE THE TIMEOUT TO PASS THESE TESTS ON CI (GITHUB ACTIONS)
3736 database .setTimeout (60_000 );
37+ // Try to delete function first in case it exists from a previous failed test
38+ tryDeleteFunction ("math" , "sum" );
3839 database .command ("sql" , "define function math.sum \" return a + b\" parameters [a,b] language js" );
39-
4040 }
4141
4242 @ AfterEach
4343 void tearDown () {
44- database .command ("sql" , "delete function math.sum" );
44+ tryDeleteFunction ("math" , "sum" );
45+ tryDeleteFunction ("Test" , "objectComparison" );
46+ tryDeleteFunction ("Test" , "lowercase" );
4547 if (database != null ) database .close ();
4648 }
4749
50+ private void tryDeleteFunction (final String library , final String function ) {
51+ try {
52+ database .command ("sql" , "delete function " + library + "." + function );
53+ } catch (final Exception ignored ) {
54+ // Function might not exist or DELETE FUNCTION might not be supported in older versions
55+ }
56+ }
57+
4858 @ Test
4959 void jsMathSum () {
5060 final ResultSet result = database .command ("sql" , "select `math.sum`(?,?) as result" , 3 , 5 );
0 commit comments