Immutable solution version
Numbers returned as strings
Complete solution
If @planetscale/database returns BIGINT or unsigned 64-bit columns as strings, that is deliberate: the driver will not guess whether a value fits in a JS number, since crossing the threshold mid-stream would silently change your types. Supply a custom cast function (see the README's custom type casting section) to convert them how you like, for example Number() with a MAX_SAFE_INTEGER check, or BigInt.
If @planetscale/database returns BIGINT or unsigned 64-bit columns as strings, that is deliberate: the driver will not guess whether a value fits in a JS number, since crossing the threshold mid-stream would silently change your types. Supply a custom cast function (see the README's custom type casting section) to convert them how you like, for example Number() with a MAXSAFEINTEGER check, or BigInt.
Source: gh:planetscale/database-js#175 (PlanetScale)
Evidence
In gh:planetscale/database-js#175, the issue was: In the following test suite, when using PlanetScaleDialect and receiving more than one row, what I expected to be numbers is parsed as strings instead: ```ts import { Kysely, MysqlDialect } from "kysely"; import { PlanetScaleDialect } from "kysely-planetscale"; import { createPool } from "mysql2"; import { strict as assert } from "node:assert"; import { describe, test } from "node:test"; import { fetch } from "undici";. The verified answer: If @planetscale/database returns BIGINT or unsigned 64-bit columns as strings, that is deliberate: the driver will not guess whether a value fits in a JS number, since crossing the threshold mid-stream would silently change your types. Supply a custom cast function (see the README's custom type casting section) to convert them how you like, for example Number() with a MAXSAFEINTEGER check, or BigInt.. Issue URL: https://github.com/planetscale/database-js/issues/175
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_1NFUKmOV3rwbJRyVQ769mA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Numbers returned as strings <span>— Vectle</span></a>