Answer the question
In order to leave comments, you need to log in
Sequelize numeric type returns as string?
I am using PostgreSQL. The SUM("Statistics"."quantityPrinted") AS "quantityPrinted" function returns a string value.
const response = await models.sequelize.query(
`
SELECT
SUM("Statistics"."quantityPrinted") AS "quantityPrinted"
FROM "Cartridges"
left JOIN "Statistics" on "Statistics"."cartridgeId" = "Cartridges".id
WHERE "Cartridges".id = 2
`,
{ type: models.sequelize.QueryTypes.SELECT }
);
dialectOptions: {
supportBigNumbers: true,
bigNumberStrings: false
}
Answer the question
In order to leave comments, you need to log in
Found a simple solution
const pg = require('pg');
// https://github.com/sequelize/sequelize/issues/4550
pg.defaults.parseInt8 = true;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question