{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/3236","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/3236/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/3236/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/3236/events","html_url":"https://github.com/sequelize/sequelize/issues/3236","id":59263263,"number":3236,"title":"Execution of customized query return the resulting array TWICE","user":{"login":"kkcheungus","id":2387447,"avatar_url":"https://avatars.githubusercontent.com/u/2387447?v=3","gravatar_id":"","url":"https://api.github.com/users/kkcheungus","html_url":"https://github.com/kkcheungus","followers_url":"https://api.github.com/users/kkcheungus/followers","following_url":"https://api.github.com/users/kkcheungus/following{/other_user}","gists_url":"https://api.github.com/users/kkcheungus/gists{/gist_id}","starred_url":"https://api.github.com/users/kkcheungus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kkcheungus/subscriptions","organizations_url":"https://api.github.com/users/kkcheungus/orgs","repos_url":"https://api.github.com/users/kkcheungus/repos","events_url":"https://api.github.com/users/kkcheungus/events{/privacy}","received_events_url":"https://api.github.com/users/kkcheungus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-27T17:00:47Z","updated_at":"2015-03-17T00:35:25Z","closed_at":null,"body":"Execution of customized query return the resulting array TWICE.\r\n\r\nA customized query  \"userProjectsQueryString\" is executed and result return as \r\n\"projectRows\"  \r\n                  portalAdminModels.sequelize.query(userProjectsQueryString,\r\n                                                      portalAdminModels.projects,\r\n                                                      { raw:true }).then(function(projectRows)\r\n\r\nWhen viewing the projectRows as JSON string using \r\n                     console.log(JSON.stringify({\"projectRows\": projectRows}));\r\n\r\n\r\nVersion 2.0.0-rc8   correct result where projectRows is an array of \"projects\"\r\n{\r\n\"projectRows\":\r\n[\r\n{\"projectId\":1,\"projectName\":\"13002\",\"dbName\":\"proj_cancer_13002\"},\r\n{\"projectId\":2,\"projectName\":\"13006\",\"dbName\":\"proj_cancer_13006\"},\r\n{\"projectId\":3,\"projectName\":\"13007\",\"dbName\":\"proj_cancer_13007\"},\r\n{\"projectId\":4,\"projectName\":\"13008\",\"dbName\":\"proj_cancer_13008\"},\r\n{\"projectId\":5,\"projectName\":\"13010\",\"dbName\":\"proj_cancer_13010\"},\r\n{\"projectId\":6,\"projectName\":\"13015\",\"dbName\":\"proj_cancer_13015\"}\r\n]\r\n\r\n}\r\n\r\n\r\nVersion 2.0.3\r\n{\r\n\"projectRows\":\r\n[\r\n\r\n[\r\n{\"projectId\":1,\"projectName\":\"13002\",\"dbName\":\"proj_cancer_13002\"},\r\n{\"projectId\":2,\"projectName\":\"13006\",\"dbName\":\"proj_cancer_13006\"},\r\n{\"projectId\":3,\"projectName\":\"13007\",\"dbName\":\"proj_cancer_13007\"},\r\n{\"projectId\":4,\"projectName\":\"13008\",\"dbName\":\"proj_cancer_13008\"},\r\n{\"projectId\":5,\"projectName\":\"13010\",\"dbName\":\"proj_cancer_13010\"},\r\n{\"projectId\":6,\"projectName\":\"13015\",\"dbName\":\"proj_cancer_13015\"}\r\n],\r\n\r\n[\r\n{\"projectId\":1,\"projectName\":\"13002\",\"dbName\":\"proj_cancer_13002\"},\r\n{\"projectId\":2,\"projectName\":\"13006\",\"dbName\":\"proj_cancer_13006\"},\r\n{\"projectId\":3,\"projectName\":\"13007\",\"dbName\":\"proj_cancer_13007\"},\r\n{\"projectId\":4,\"projectName\":\"13008\",\"dbName\":\"proj_cancer_13008\"},\r\n{\"projectId\":5,\"projectName\":\"13010\",\"dbName\":\"proj_cancer_13010\"},\r\n{\"projectId\":6,\"projectName\":\"13015\",\"dbName\":\"proj_cancer_13015\"}\r\n]\r\n\r\n]\r\n\r\n\r\n\r\n}\r\n\r\n\r\nActual code:\r\n\r\nexports.findUserByUserId = function(userId, callbackFunction) {\r\n    //console.log(\"PortalAdminDatabase = \" + portalAdminDatabase);\r\n    //portalAdminModels.sequelize.query(\"USE \" + portalAdminDatabase).then(function() {\r\n    //models.users.schema(portalAdminDatabase);\r\n    portalAdminModels.users.find(\r\n        {   where:   {userId: userId},\r\n        }).then(function(loginUser) {\r\n            var userProjectsQueryString = \r\n                    \"select distinct \" +\r\n                    \"p.projectId, p.projectName, p.dbName \" +\r\n                    \"from \" + portalAdminDatabase + \".users u \" +\r\n                    \"join \" + portalAdminDatabase + \".usersGroups  ug \" +\r\n                    \"on u.userId = ug.userId \" +\r\n                    \"join \" + portalAdminDatabase + \".groups g \" +\r\n                    \"on ug.groupId = g.groupId \" + \r\n                    \"join \" + portalAdminDatabase + \".groupsProjects gp \" +\r\n                    \"on g.groupId = gp.groupId \" +\r\n                    \"join \" + portalAdminDatabase + \".projects p \" +\r\n                    \"on gp.projectId = p.projectId \" +\r\n                    \"where u.userId =  \" + userId +\r\n                    \" order by p.projectName\" ;\r\n\r\n                    //console.log(\"CUSTOMIZED SQL TO FIND PROJECTS for UserId \" + userId); \r\n                    //console.log(userProjectsQueryString);\r\n                    portalAdminModels.sequelize.query(userProjectsQueryString,\r\n                                                      portalAdminModels.projects,\r\n                                                      { raw:true }).then(function(projectRows) { \r\n                     loginUser.projects = projectRows;\r\n                     console.log(JSON.stringify({\"projectRows\": projectRows}));\r\n                     console.log(loginUser);\r\n                     callbackFunction(loginUser);\r\n                    });\r\n            });\r\n    //});\r\n};"},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/82005541","html_url":"https://github.com/sequelize/sequelize/issues/3236#issuecomment-82005541","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/3236","id":82005541,"user":{"login":"streetkid","id":9124117,"avatar_url":"https://avatars.githubusercontent.com/u/9124117?v=3","gravatar_id":"","url":"https://api.github.com/users/streetkid","html_url":"https://github.com/streetkid","followers_url":"https://api.github.com/users/streetkid/followers","following_url":"https://api.github.com/users/streetkid/following{/other_user}","gists_url":"https://api.github.com/users/streetkid/gists{/gist_id}","starred_url":"https://api.github.com/users/streetkid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/streetkid/subscriptions","organizations_url":"https://api.github.com/users/streetkid/orgs","repos_url":"https://api.github.com/users/streetkid/repos","events_url":"https://api.github.com/users/streetkid/events{/privacy}","received_events_url":"https://api.github.com/users/streetkid/received_events","type":"User","site_admin":false},"created_at":"2015-03-17T00:35:25Z","updated_at":"2015-03-17T00:35:25Z","body":"I've also noticed that when doing raw Queries, the resulting array is \r\n[ [ { object } ] ] in 2.0.4\r\n where in 2.0.0 I get [ {object} ] \r\n\r\nIs this caused by the same reason? \r\n"}}