Giter VIP home page Giter VIP logo

Comments (4)

composerinteralia avatar composerinteralia commented on July 20, 2024 1

Casting to an Integer when SUMming int columns makes sense to me. I don't think it's too difficult (we already get back information about whether the column includes decimals). I can open a PR later today.

from trilogy.

adrianna-chang-shopify avatar adrianna-chang-shopify commented on July 20, 2024

Awesome, thanks Daniel! 🙏 ❤️

from trilogy.

dbussink avatar dbussink commented on July 20, 2024

I'm wondering if this is a bug, or if I'm just missing a query option to cast the result to an Integer properly. At Shopify we're using Sorbet, and it complains loudly if a query ends up returning a BigDecimal when it was expecting an Integer.

Fwiw, this is part of how MySQL itself functions. A SUM() also on integer types always casts to DECIMAL since there's no guarantee otherwise that the result fits. A SUM over bigint columns could easily overflow a bigint.

This is different from COUNT for example which returns a bigint since that's also the maximum number of rows. Also see https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html.

I'd argue to be honest here that Sorbet is wrong here. It should expect a DECIMAL like type for a SUM query and not really an integer. Anyway, the ship here probably long ago sailed on these changes.

from trilogy.

composerinteralia avatar composerinteralia commented on July 20, 2024

I vaguely recall wanting to do this to match what the mysql2 gem does, to make it easier for folks switching over from that gem. We decided against making this change at GitHub and made it configurable in #60, in case that is helpful.

from trilogy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.