Last active
August 29, 2015 14:19
-
-
Save nagarajasr/2dc4995b9a8067b3c617 to your computer and use it in GitHub Desktop.
SQL function calling javascript function in a subquery does not work as expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create class buyer extends V | |
create class item extends V | |
create property item.quantity String | |
create class bought extends E | |
create vertex buyer | |
create vertex item set quantity=3 | |
create edge from (select from buyer) to (select from item) | |
func1_javascript: input parameters A and B | |
------------------------------------------ | |
var my_a = parseInt(A); | |
var my_b = parseInt(B); | |
var sum = my_a + my_b; | |
return sum; | |
func2_sql (using subquery, does not give any results): | |
-------------------------------------- | |
select from (select expand(in(bought)) from item where quantity < func1_javascript($A,$B)) | |
func3_sql (gives the expected results): | |
------------------------------- | |
select expand(in(bought)) from item where quantity < func1_javascript($A,$B) | |
if the parameter values are hardcoded, as below, then it gives the expected results | |
func4_sql (gives the expected results): | |
--------------------------------------- | |
select from (select expand(in(bought)) from item where quantity < func1_javascript(2,3)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment