{"action":"closed","issue":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/5834","repository_url":"https://api.github.com/repos/orientechnologies/orientdb","labels_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/5834/labels{/name}","comments_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/5834/comments","events_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/5834/events","html_url":"https://github.com/orientechnologies/orientdb/issues/5834","id":141167349,"number":5834,"title":"Strange behaviour in JS functions","user":{"login":"warriorkitty","id":5781483,"avatar_url":"https://avatars.githubusercontent.com/u/5781483?v=3","gravatar_id":"","url":"https://api.github.com/users/warriorkitty","html_url":"https://github.com/warriorkitty","followers_url":"https://api.github.com/users/warriorkitty/followers","following_url":"https://api.github.com/users/warriorkitty/following{/other_user}","gists_url":"https://api.github.com/users/warriorkitty/gists{/gist_id}","starred_url":"https://api.github.com/users/warriorkitty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/warriorkitty/subscriptions","organizations_url":"https://api.github.com/users/warriorkitty/orgs","repos_url":"https://api.github.com/users/warriorkitty/repos","events_url":"https://api.github.com/users/warriorkitty/events{/privacy}","received_events_url":"https://api.github.com/users/warriorkitty/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/orientechnologies/orientdb/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"luigidellaquila","id":459289,"avatar_url":"https://avatars.githubusercontent.com/u/459289?v=3","gravatar_id":"","url":"https://api.github.com/users/luigidellaquila","html_url":"https://github.com/luigidellaquila","followers_url":"https://api.github.com/users/luigidellaquila/followers","following_url":"https://api.github.com/users/luigidellaquila/following{/other_user}","gists_url":"https://api.github.com/users/luigidellaquila/gists{/gist_id}","starred_url":"https://api.github.com/users/luigidellaquila/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luigidellaquila/subscriptions","organizations_url":"https://api.github.com/users/luigidellaquila/orgs","repos_url":"https://api.github.com/users/luigidellaquila/repos","events_url":"https://api.github.com/users/luigidellaquila/events{/privacy}","received_events_url":"https://api.github.com/users/luigidellaquila/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-03-16T04:08:43Z","updated_at":"2016-03-16T11:26:36Z","closed_at":"2016-03-16T11:26:36Z","body":"Hi all! First of all, this is the first version of the algorithm, so I know things could get done little better. I'm implementing Pearson's correlation coefficient.\r\n\r\n1. get all movies I rated\r\n2. get all movies from other users\r\n3. find intersections\r\n4. calculate the similarity coefficient\r\n\r\nLook at the line before `return movies`. If I execute queries directly, I get the list of movies for `userId = 1`.\r\n\r\n```javascript\r\nvar gdb = orient.getGraph();\r\n\r\n// get all movies from user\r\nvar movies = gdb.command( \"sql\", \"select movieId, name from (select expand(out('Rate')) from User where userId = ?);\", [ userId ] );\r\n\r\nvar allUsers = gdb.command( \"sql\", \"select userId from User;\" );\r\n\r\nfor(var i = 0; i < allUsers.length; ++i) {\r\n  var user = allUsers[i];\r\n  \r\n  // get all movies user rated\r\n  var movies = gdb.command( \"sql\", \"select movieId, name from (select expand(out('Rate')) from User where userId = ?);\", [ user.userId ] );\r\n  \r\n  // testing\r\n  return movies;\r\n}\r\n\r\n```\r\n\r\nWhen I return a user, I get:\r\n```\r\n[\r\n    {\r\n        \"@type\": \"d\",\r\n        \"@rid\": \"#-2:0\",\r\n        \"@version\": 0,\r\n        \"userId\": 1\r\n    }\r\n]\r\n```\r\n\r\nMy conclusion is that I cannot get the value `user.userId` from the top of the for loop. When I execute the SQL directly:\r\n\r\n```sql\r\nselect movieId, name from (select expand(out('Rate')) from User where userId = 1);\r\n```\r\nI get the results:\r\n\r\n```\r\n1       Toy Story (1995)\r\n266    Legends of the Fall (1994)\r\n```"}}