← sources

Our SQL IDE could silently save an edit to the wrong row. Root cause: JavaScript rounds integers past 2^53.

source: reddit (reddit:selfhosted)published 2026-09-20 12:12ingested 2026-09-21 02:37

retained text

LibreDB Studio is a self-hosted, open-source (MIT) SQL IDE for 16 external database engines plus its own embedded store. Just shipped 0.16.1, and this is the fix that worried me most.

The inline row editor identifies which row to update by asking the engine for a row matching the key you loaded. Three drivers, MySQL and both SQLite drivers, hand back integer ids as native JavaScript numbers, which only hold 53 bits of exact precision. Once a table's primary key passes 2\^53 (about 9 quadrillion, so any 64-bit auto-increment far enough along, or a distributed id generator), two rows whose ids differ only in the low digits round to the same JS number. The editor asked the engine who has this id, got one of the two rows back, and sent the UPDATE to whichever one answered, not necessarily the one you actually edited. node:sqlite threw ERR\_OUT\_OF\_RANGE instead of rounding silently, which turned out to be the same bug wearing a louder alarm.

Fix: MySQL now sets supportBigNumbers so it returns a string once precision would be lost. SQLite and libsql convert at the provider boundary the same way: a value that fits comes back as a number, one that does not comes back as its exact decimal string, and no BigInt ever leaves a provider. The write path mirrors this, only a digit string the read side could itself have produced round trips as a 64 bit integer.

Found alongside eight other correctness bugs in the same PR (a schema diff panel losing snapshots, six user facing refusal messages describing the wrong condition), each reproduced against a live engine before being touched and pinned by a test that fails without the fix.

PR with the full writeup: [https://github.com/libredb/libredb-studio/pull/969](https://github.com/libredb/libredb-studio/pull/969)

Release notes: [https://github.com/libredb/libredb-studio/releases/tag/0.16.1](https://github.com/libredb/libredb-studio/releases/tag/0.16.1)

Repo: [https://github.com/libredb/libredb-studio](https://github.com/libredb/libredb-studio)

Curious whether anyone else running a GUI against a database with 64-bit IDs has actually checked whether their tool round-trips IDs past 2\^53 correctly. Easy one to never notice until it silently corrupts something.

document fetched 2026-09-21 00:28 · canonical https://reddit.com/r/selfhosted/comments/1wlfgws/our_sql_ide_could_silently_save_an_edit_to_the