{"action":"closed","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/5979","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/5979/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/5979/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/5979/events","html_url":"https://github.com/sequelize/sequelize/issues/5979","id":157208186,"number":5979,"title":"s.replace is not a function on sequelize.fn 'AVG'","user":{"login":"sadaf2605","id":2094165,"avatar_url":"https://avatars.githubusercontent.com/u/2094165?v=3","gravatar_id":"","url":"https://api.github.com/users/sadaf2605","html_url":"https://github.com/sadaf2605","followers_url":"https://api.github.com/users/sadaf2605/followers","following_url":"https://api.github.com/users/sadaf2605/following{/other_user}","gists_url":"https://api.github.com/users/sadaf2605/gists{/gist_id}","starred_url":"https://api.github.com/users/sadaf2605/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sadaf2605/subscriptions","organizations_url":"https://api.github.com/users/sadaf2605/orgs","repos_url":"https://api.github.com/users/sadaf2605/repos","events_url":"https://api.github.com/users/sadaf2605/events{/privacy}","received_events_url":"https://api.github.com/users/sadaf2605/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-27T13:35:53Z","updated_at":"2016-05-27T14:03:13Z","closed_at":"2016-05-27T14:03:13Z","body":"## What you are doing?\r\nI have this following code:\r\n\r\n```js\r\n/*\r\nSELECT \"UserRole\", Avg(rating)  FROM \"Reviews\" AS \"Review\" GROUP BY \"UserRole\";\r\n UserRole |        avg         \r\n----------+--------------------\r\n COACH | 2.0000000000000000\r\n PLAYER | 3.0000000000000000\r\n(2 rows)\r\n\r\n*/\r\nrouter.get(\"/as\",function(request,response){\r\n  model.Review.find({\r\n      where: { UserId: 1},\r\n      attributes: [ \"UserRole\", [ sequelize.fn('AVG', sequelize.col('rating')) ]],  \r\n      group: [\"UserRole\"],\r\n      \r\n      \r\n    }).then(function(ratings){\r\n\r\n    })\r\n\r\n})\r\n```\r\n\r\n## What do you expect to happen?\r\nI expect it to return something like this:\r\n'''\r\n COACH | 2.0000000000000000\r\n PLAYER | 3.0000000000000000\r\n\r\n'''\r\n## What is actually happening?\r\n'''\r\nUnhandled rejection TypeError: s.replace is not a function\r\n    at Object.module.exports.removeTicks (/media/mydata/projects/jobcuejs/node_modules/sequelize/lib/utils.js:376:14)\r\n    at Object.module.exports.addTicks (/media/mydata/projects/jobcuejs/node_modules/sequelize/lib/utils.js:372:29)\r\n    at Object.QueryGenerator.quoteIdentifier (/media/mydata/projects/jobcuejs/node_modules/sequelize/lib/dialects/postgres/query-generator.js:844:20)\r\n    at Object.QueryGenerator.quoteIdentifiers (/media/mydata/projects/jobcuejs/node_modules/sequelize/lib/dialects/abstract/query-generator.js:937:19)\r\n    at /media/mydata/projects/jobcuejs/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1080:82\r\n    at Array.map (native)\r\n    at Object.QueryGenerator.selectQuery (/media/mydata/projects/jobcuejs/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1062:55)\r\n    at QueryInterface.select (/media/mydata/projects/jobcuejs/node_modules/sequelize/lib/query-interface.js:661:25)\r\n    at null.<anonymous> (/media/mydata/projects/jobcuejs/node_modules/sequelize/lib/model.js:1413:32)\r\n    at tryCatcher (/media/mydata/projects/jobcuejs/node_modules/bluebird/js/release/util.js:16:23)\r\n    at Promise._settlePromiseFromHandler (/media/mydata/projects/jobcuejs/node_modules/bluebird/js/release/promise.js:503:31)\r\n    at Promise._settlePromise (/media/mydata/projects/jobcuejs/node_modules/bluebird/js/release/promise.js:560:18)\r\n    at Promise._settlePromise0 (/media/mydata/projects/jobcuejs/node_modules/bluebird/js/release/promise.js:605:10)\r\n    at Promise._settlePromises (/media/mydata/projects/jobcuejs/node_modules/bluebird/js/release/promise.js:684:18)\r\n    at Async._drainQueue (/media/mydata/projects/jobcuejs/node_modules/bluebird/js/release/async.js:126:16)\r\n    at Async._drainQueues (/media/mydata/projects/jobcuejs/node_modules/bluebird/js/release/async.js:136:10)\r\n'''\r\n\r\nOn my database query it works:\r\n'''\r\nSELECT \"UserRole\", Avg(rating)  FROM \"Reviews\" AS \"Review\" GROUP BY \"UserRole\";\r\n UserRole |        avg         \r\n----------+--------------------\r\n COACH | 2.0000000000000000\r\n PLAYER | 3.0000000000000000\r\n(2 rows)\r\n'''\r\n\r\n__Dialect:__ postgres\r\n__Database version:__ 9.5\r\n__Sequelize version:__ ^3.20.0\r\n'''\r\n$ sequelize version\r\n\r\nSequelize [Node: 4.2.6, CLI: 2.4.0, ORM: 3.21.0, pg: ^4.5.2]\r\n'''"}}
{"actor":{"display_login":"sadaf2605"}}