question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aggregate query returns SUM as strings instead of integers

See original GitHub issue

I dont know if it is normal, or if there is something I am doing wrong, but the sums returned by my query below are in strings even if the datatype of nbrEleves field is integer. Why? The query is run against a postgres database.

Point.aggregate('nbrEleves', 'SUM', {plain: false, where: {codecs: codecs}, order: '"codeSecteur" ASC', group:["codeSecteur", "codeWork"], attributes:['codeSecteur', 'codeWork']})

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ms88privatcommented, Nov 4, 2015

@janmeier Thank you. I tried it like this but it did not work (my instance.update({bigint: value}) and my raw queries are still returning strings):

var pg = require('pg');
pg.defaults.parseInt8 = true;

var Sequelize = require('sequelize');
sequelize = new Sequelize ...

Any Ideas?

1reaction
bvandenboncommented, Nov 29, 2021

Still having the same issue on sequelize version “5.22.4”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why SUM(`column`) returns a string instead of an integer?
It's neither Laravel or PDO issue. According to MySQL manual, SUM() returns a DECIMAL value for exact-value arguments ( integer or DECIMAL )....
Read more >
$sum (aggregation) — MongoDB Manual
Calculates and returns the collective sum of numeric values. $sum ignores non-numeric values. $sum is available in these stages:.
Read more >
Documentation: 9.2: Aggregate Functions
In particular, sum of no rows returns null, not zero as one might expect, and array_agg returns null rather than an empty array...
Read more >
Using cast inside sum or outside ? - Microsoft Q&A
In my opinion, if you have 1000 numbers, for example, then it is better to have a single cast instead of 1000 casts....
Read more >
Aggregate Functions
An aggregate function always returns exactly one row, even when the input contains zero rows. Typically, if the input contained zero rows, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found