Comments (4)
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.
Awesome, thanks Daniel! 🙏 ❤️
from trilogy.
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 anInteger
.
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.
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)
- Use memset_s() instead of memset() to clear passwords
- Prepared Statements: Ruby support HOT 5
- Improved Ruby error classes HOT 6
- Compile Ruby in parallel
- Trilogy::SSLError is raised when a vitess vtgate is shut down HOT 2
- Client returns TRILOGY_INVALID_SEQUENCE_ID HOT 1
- CI for old Rubies doesn't work correctly
- failed install on windows 11 with mysys64 HOT 1
- [Ruby] Potential compaction issue in `rb_trilogy_connect`? HOT 2
- Include field names when using `query`. HOT 9
- `Trilogy.connect` not working in Staging and Production environments. HOT 8
- How did you solve the connection "feature" that translates `localhost` to a local UNIX socket? HOT 1
- Support for cleartext password
- Connection Fails in GitHub Actions HOT 3
- `trilogy` can't connect to remote Rails db, but `mysql2` can with identical `database.yml` HOT 1
- A more native GitHub Actions workflow would be nice HOT 2
- Add configuration option for SSL_OP_IGNORE_UNEXPECTED_EOF? HOT 1
- [Ruby] Add a Pipelining API?
- Make C-extension Ractor-safe HOT 1
- Non-C extension support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trilogy.