kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
10.46k stars 268 forks source link

Large offsets are converted to scientific notation #987

Closed phibr0 closed 4 months ago

phibr0 commented 4 months ago

It seems like kysely converts numbers to strings simply by calling .toString(). This breaks for numbers larger than one million, because those numbers are converted to scientific notation:

Example

ctx.db
  .selectFrom('person')
  .select('first_name')
  .offset(4_000_000)
Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4e+06' at line 1

4,000,000 gets converted to 4e+06 which is $4\times 10^6$.

koskimas commented 4 months ago

Kysely does no such thing https://kyse.link/whZiN

Kysely sends all user input as parameters. It's up to the underlying driver to handle how they are sent over the wire. I find it hard to believe that mysql2 would do that either though.