Sequelize返回与原始查询不同的值

当我运行这个function

function getOpenTxCalls(date) { return sequelize.query( 'SELECT \ CT.center_name, \ 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", \ COUNT(CASE WHEN CL.disposition_type = 3 AND CL."createdAt"::date = :date THEN CL.disposition_type END) AS "AppointmentsMadeToday" \ FROM "Centers" AS CT \ LEFT JOIN "Users" AS US ON US."centerId" = CT.id \ LEFT JOIN "CallLogs" AS CL ON CL."createdBy" = US."id" \ WHERE US."centerId" NOT IN(11, 13)\ GROUP BY CT.center_name \ ORDER BY CT.center_name', { replacements: { date: date }, type: sequelize.QueryTypes.SELECT }) .then(function(openTXCalls) { console.log(openTXCalls); return openTXCalls; }) .catch(console.log.bind(console)); } 

这是返回不正确的数据。

我在运行该函数时观察了CLI,并将CLI中的SQL查询复制并粘贴到PG3 Admin中,并接收到不同的(正确的)值。 这是CLI中的内容。

 Executing (default): SELECT CT.center_name, COUNT(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", COUNT(CASE WHEN CL.disposition_type = 3 AND CL."createdAt"::date = '2016-02-17' THEN CL.disposition_type END) AS "AppointmentsMadeToday" FROM "Centers" AS CT LEFT JOIN "Users" AS US ON US."centerId" = CT.id LEFT JOIN "CallLogs" AS CL ON CL."createdBy" = US."id" WHERE US."centerId" NOT IN(11, 13) GROUP BY CT.center_name ORDER BY CT.center_name 

我在我的机器上查询同一个本地Postgres数据库。 有什么想法可能造成这个?

       

网上收集的解决方案 "Sequelize返回与原始查询不同的值"