@@ -38,14 +38,14 @@ void testSQLFunctionWithStringParameter() throws Exception {
3838 db .command ("sql" , "CREATE DOCUMENT TYPE Beer" );
3939 db .command ("sql" , "INSERT INTO Beer SET name = 'Hocus Pocus'" );
4040 db .command ("sql" , "INSERT INTO Beer SET name = 'Leffe'" );
41-
41+
4242 // Define a function that retrieves data using a string argument
4343 db .command ("sql" , "DEFINE FUNCTION my.getBeerId \" SELECT @rid AS result FROM `Beer` WHERE name=:a\" PARAMETERS [a] LANGUAGE sql" );
44-
44+
4545 // Call the function with a string parameter
4646 final ResultSet result = db .query ("sql" , "SELECT `my.getBeerId`('Hocus Pocus') as beerRid" );
4747 assertThat (result .hasNext ()).isTrue ();
48-
48+
4949 final Object beerRid = result .next ().getProperty ("beerRid" );
5050 assertThat (beerRid ).isNotNull ();
5151 // The RID should be a valid RID format (e.g., #1:0)
@@ -58,11 +58,11 @@ void testSQLFunctionReturningInput() throws Exception {
5858 TestHelper .executeInNewDatabase ("testSQLFunctionReturningInput" , (db ) -> {
5959 // Define a function that returns the input directly
6060 db .command ("sql" , "DEFINE FUNCTION my.returnInput \" SELECT :a AS result\" PARAMETERS [a] LANGUAGE sql" );
61-
61+
6262 // Call the function with a string parameter
6363 final ResultSet result = db .query ("sql" , "SELECT `my.returnInput`('Hocus Pocus') as output" );
6464 assertThat (result .hasNext ()).isTrue ();
65-
65+
6666 final String output = result .next ().getProperty ("output" );
6767 assertThat (output ).isEqualTo ("Hocus Pocus" );
6868 });
@@ -73,11 +73,11 @@ void testSQLFunctionWithMultipleParameters() throws Exception {
7373 TestHelper .executeInNewDatabase ("testSQLFunctionWithMultipleParameters" , (db ) -> {
7474 // Define a function that uses multiple parameters
7575 db .command ("sql" , "DEFINE FUNCTION my.add \" SELECT :a + :b AS result\" PARAMETERS [a, b] LANGUAGE sql" );
76-
76+
7777 // Call the function with multiple numeric parameters
7878 final ResultSet result = db .query ("sql" , "SELECT `my.add`(10, 20) as output" );
7979 assertThat (result .hasNext ()).isTrue ();
80-
80+
8181 final Integer output = result .next ().getProperty ("output" );
8282 assertThat (output ).isEqualTo (30 );
8383 });
@@ -88,11 +88,11 @@ void testJavaScriptFunctionReturningInput() throws Exception {
8888 TestHelper .executeInNewDatabase ("testJavaScriptFunctionReturningInput" , (db ) -> {
8989 // Define a JavaScript function that returns the input
9090 db .command ("sql" , "DEFINE FUNCTION my.returnInputJS \" return a\" PARAMETERS [a] LANGUAGE js" );
91-
91+
9292 // Call the function with a string parameter
9393 final ResultSet result = db .query ("sql" , "SELECT `my.returnInputJS`('Hocus Pocus') as output" );
9494 assertThat (result .hasNext ()).isTrue ();
95-
95+
9696 final String output = result .next ().getProperty ("output" );
9797 assertThat (output ).isEqualTo ("Hocus Pocus" );
9898 });
@@ -103,11 +103,11 @@ void testJavaScriptFunctionWithStringParameter() throws Exception {
103103 TestHelper .executeInNewDatabase ("testJavaScriptFunctionWithStringParameter" , (db ) -> {
104104 // Define a JavaScript function that manipulates a string
105105 db .command ("sql" , "DEFINE FUNCTION my.uppercase \" return a.toUpperCase()\" PARAMETERS [a] LANGUAGE js" );
106-
106+
107107 // Call the function with a string parameter
108108 final ResultSet result = db .query ("sql" , "SELECT `my.uppercase`('hello world') as output" );
109109 assertThat (result .hasNext ()).isTrue ();
110-
110+
111111 final String output = result .next ().getProperty ("output" );
112112 assertThat (output ).isEqualTo ("HELLO WORLD" );
113113 });
@@ -118,11 +118,11 @@ void testJavaScriptFunctionWithMultipleParameters() throws Exception {
118118 TestHelper .executeInNewDatabase ("testJavaScriptFunctionWithMultipleParameters" , (db ) -> {
119119 // Define a JavaScript function with multiple parameters
120120 db .command ("sql" , "DEFINE FUNCTION my.add \" return a + b\" PARAMETERS [a, b] LANGUAGE js" );
121-
121+
122122 // Call the function with numeric parameters
123123 final ResultSet result = db .query ("sql" , "SELECT `my.add`(10, 20) as output" );
124124 assertThat (result .hasNext ()).isTrue ();
125-
125+
126126 final Integer output = result .next ().getProperty ("output" );
127127 assertThat (output ).isEqualTo (30 );
128128 });
@@ -133,11 +133,11 @@ void testJavaScriptFunctionWithStringContainingQuotes() throws Exception {
133133 TestHelper .executeInNewDatabase ("testJavaScriptFunctionWithStringContainingQuotes" , (db ) -> {
134134 // Define a JavaScript function that handles strings
135135 db .command ("sql" , "DEFINE FUNCTION my.echo \" return a\" PARAMETERS [a] LANGUAGE js" );
136-
136+
137137 // Call the function with a string containing special characters
138138 final ResultSet result = db .query ("sql" , "SELECT `my.echo`('It\\ 's a \" test\" ') as output" );
139139 assertThat (result .hasNext ()).isTrue ();
140-
140+
141141 final String output = result .next ().getProperty ("output" );
142142 assertThat (output ).isEqualTo ("It's a \" test\" " );
143143 });
@@ -148,11 +148,11 @@ void testSQLFunctionWithNumericParameter() throws Exception {
148148 TestHelper .executeInNewDatabase ("testSQLFunctionWithNumericParameter" , (db ) -> {
149149 // Define a function that works with numbers
150150 db .command ("sql" , "DEFINE FUNCTION my.double \" SELECT :a * 2 AS result\" PARAMETERS [a] LANGUAGE sql" );
151-
151+
152152 // Call the function with a numeric parameter
153153 final ResultSet result = db .query ("sql" , "SELECT `my.double`(21) as output" );
154154 assertThat (result .hasNext ()).isTrue ();
155-
155+
156156 final Integer output = result .next ().getProperty ("output" );
157157 assertThat (output ).isEqualTo (42 );
158158 });
@@ -163,11 +163,11 @@ void testJavaScriptFunctionWithBooleanParameter() throws Exception {
163163 TestHelper .executeInNewDatabase ("testJavaScriptFunctionWithBooleanParameter" , (db ) -> {
164164 // Define a JavaScript function that works with booleans
165165 db .command ("sql" , "DEFINE FUNCTION my.negate \" return !a\" PARAMETERS [a] LANGUAGE js" );
166-
166+
167167 // Call the function with a boolean parameter
168168 final ResultSet result = db .query ("sql" , "SELECT `my.negate`(true) as output" );
169169 assertThat (result .hasNext ()).isTrue ();
170-
170+
171171 final Boolean output = result .next ().getProperty ("output" );
172172 assertThat (output ).isFalse ();
173173 });
0 commit comments