{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/5459","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/5459/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/5459/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/5459/events","html_url":"https://github.com/sequelize/sequelize/issues/5459","id":134987954,"number":5459,"title":"Sequelize returning different values than the raw query","user":{"login":"jeffprandall","id":119567,"avatar_url":"https://avatars.githubusercontent.com/u/119567?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffprandall","html_url":"https://github.com/jeffprandall","followers_url":"https://api.github.com/users/jeffprandall/followers","following_url":"https://api.github.com/users/jeffprandall/following{/other_user}","gists_url":"https://api.github.com/users/jeffprandall/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffprandall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffprandall/subscriptions","organizations_url":"https://api.github.com/users/jeffprandall/orgs","repos_url":"https://api.github.com/users/jeffprandall/repos","events_url":"https://api.github.com/users/jeffprandall/events{/privacy}","received_events_url":"https://api.github.com/users/jeffprandall/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-02-19T22:08:15Z","updated_at":"2016-02-23T17:16:20Z","closed_at":null,"body":"When I run this function\r\n\r\n```\r\nfunction getOpenTxCalls(date) {\r\n return sequelize.query(\r\n 'SELECT \\\r\n  CT.center_name, \\\r\n  COUNT(CASE WHEN CL.disposition_type IN(3, 4, 22, 23,25, 42) AND CL.\"createdAt\"::date = :date THEN CL.disposition_type END) AS \"CallsMadeToday\", \\\r\n  COUNT(CASE WHEN CL.disposition_type = 3 AND CL.\"createdAt\"::date = :date THEN CL.disposition_type END) AS \"AppointmentsMadeToday\" \\\r\nFROM \"Centers\" AS CT \\\r\n LEFT JOIN \"Users\" AS US ON US.\"centerId\" = CT.id \\\r\n LEFT JOIN \"CallLogs\" AS CL ON CL.\"createdBy\" = US.\"id\"  \\\r\nWHERE US.\"centerId\" NOT IN(11, 13)\\\r\nGROUP BY CT.center_name \\\r\nORDER BY CT.center_name',\r\n{ replacements:\r\n  {\r\n    date: date\r\n  },\r\n  type: sequelize.QueryTypes.SELECT })\r\n.then(function(openTXCalls) {\r\n  console.log(openTXCalls);\r\n  return openTXCalls;\r\n})\r\n.catch(console.log.bind(console));\r\n}\r\n```\r\nIt's returning incorrect counts of data.\r\n\r\nI watched the CLI as I ran the function and copy and pasted the SQL query in CLI into PG3 Admin and received different (correct) values. Here is what was in the CLI.\r\n\r\n```\r\nExecuting (default): SELECT     \r\nCT.center_name,     \r\nCOUNT(CASE WHEN    CL.disposition_type IN(3, 4, 22, 23,25, 42) AND CL.\"createdAt\"::date = '2016-02-17' THEN CL.disposition_type END) AS \"CallsMadeToday\",     \r\nCOUNT(CASE WHEN CL.disposition_type = 3 AND CL.\"createdAt\"::date = '2016-02-17' THEN CL.disposition_type END) AS \"AppointmentsMadeToday\"   \r\nFROM \"Centers\" AS CT     \r\nLEFT JOIN \"Users\" AS US ON US.\"centerId\" = CT.id     \r\nLEFT JOIN \"CallLogs\" AS CL ON CL.\"createdBy\" = US.\"id\"    \r\nWHERE US.\"centerId\" NOT IN(11, 13)  \r\nGROUP BY CT.center_name   \r\nORDER BY CT.center_name\r\n```\r\nI am querying the same local Postgres database on my machine. Any thoughts on what could be causing this?"},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/187797107","html_url":"https://github.com/sequelize/sequelize/issues/5459#issuecomment-187797107","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/5459","id":187797107,"user":{"login":"janmeier","id":1210224,"avatar_url":"https://avatars.githubusercontent.com/u/1210224?v=3","gravatar_id":"","url":"https://api.github.com/users/janmeier","html_url":"https://github.com/janmeier","followers_url":"https://api.github.com/users/janmeier/followers","following_url":"https://api.github.com/users/janmeier/following{/other_user}","gists_url":"https://api.github.com/users/janmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/janmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janmeier/subscriptions","organizations_url":"https://api.github.com/users/janmeier/orgs","repos_url":"https://api.github.com/users/janmeier/repos","events_url":"https://api.github.com/users/janmeier/events{/privacy}","received_events_url":"https://api.github.com/users/janmeier/received_events","type":"User","site_admin":false},"created_at":"2016-02-23T17:16:20Z","updated_at":"2016-02-23T17:16:20Z","body":"The timezone of the server - when console.log a date on the server, it wil always be shown in the timezone of the server"}}