Skip to content

fix(grid): stop a typed boolean becoming 0, and widen the production gate - #531

Merged
EVWorth merged 1 commit into
mainfrom
fix/grid-boolean-and-safety-gate
Aug 30, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/grid-boolean-and-safety-gate

Conversation

@EVWorth

@EVWorth EVWorth commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Refs #415, #421. Two ways a statement could do something other than what it looked like.

A typed boolean became its opposite (#421)

A TINYINT(1) cell renders as a checkbox, but double-clicking opens a text field, and whatever was typed went into the UPDATE unchanged. MySQL accepts a string for a boolean column and converts a non-numeric one to 0 — so typing true set the column to false. The statement succeeded, so nothing reported it.

Boolean columns now parse the spellings people actually type — true/false, yes/no, on/off, t/f, 1/0, any case — and refuse anything else rather than guessing, since guessing is exactly what produced the wrong value. An unreadable cell is marked invalid and keeps focus; blurring reverts rather than committing something the server would reinterpret.

The production gate had holes on both sides (#415)

const DESTRUCTIVE_PATTERN = /\b(DROP|DELETE|TRUNCATE|ALTER)\b/i;

Missed entirely: RENAME TABLE, GRANT, REVOKE, SET PASSWORD, LOCK TABLES, KILL, CREATE USER, DROP USER — all irreversible or privilege-changing. And it matched keywords inside strings and comments, so WHERE msg = 'DROP TABLE users' prompted for nothing.

Both directions now go through one place that strips what the server ignores first.

The subtle part: conditional comments are deliberately kept. /*! DROP */ is not a comment to MySQL — it executes the contents — so stripping it like an ordinary comment is precisely how /*! DROP */ TABLE users reads as harmless while dropping the table. Their inner SQL is unwrapped (version prefix removed) and checked like anything else. There's a test for it.

UPDATE and INSERT are still not prompted for. They're the ordinary business of a database client, and a dialog on every one teaches people to dismiss it — which costs more than it saves.

Verification

11 tests on the safety check (including the conditional-comment bypass and both false-positive directions), 2 on boolean parsing. 1687 unit tests and 292 browser-mode tests — I ran both this time, after CI caught the browser suite on #529 where I'd only run the unit one.

🤖 Generated with Claude Code

…gate

Two ways a statement could do something other than what it looked like.

A TINYINT(1) cell can be typed into as well as ticked, and whatever was typed
went straight into the UPDATE. MySQL accepts a string for a boolean column and
converts a non-numeric one to 0, so typing "true" set the column to false —
the opposite of the intent — and the statement succeeded, so nothing reported
it. Boolean columns now parse the spellings people actually type (true/false,
yes/no, on/off, t/f, 1/0, any case) and refuse anything else rather than
guessing, since guessing is what produced the wrong value. A cell that cannot
be read is marked invalid and keeps focus instead of being written; leaving it
reverts rather than committing something the server would reinterpret.

The production confirmation matched DROP, DELETE, TRUNCATE and ALTER as a bare
regex over the raw text. It missed RENAME TABLE, GRANT, REVOKE, SET PASSWORD,
LOCK TABLES, KILL, CREATE USER and DROP USER, all irreversible or
privilege-changing. It also matched keywords inside string literals and
comments, so `WHERE msg = 'DROP TABLE users'` prompted for nothing.

Both directions now go through one place that strips what the server ignores
first. Conditional comments are deliberately kept: `/*! DROP */` is not a
comment to MySQL, it executes the contents, so removing it like an ordinary
comment is precisely how `/*! DROP */ TABLE users` read as harmless while
dropping the table. Their inner SQL is unwrapped and checked like anything
else.

UPDATE and INSERT are still not prompted for. They are the ordinary business
of a database client, and a dialog on every one teaches people to dismiss it,
which costs more than it saves.

Refs #415, #421
@EVWorth
EVWorth merged commit b4297c1 into main Aug 30, 2026
9 checks passed
@EVWorth
EVWorth deleted the fix/grid-boolean-and-safety-gate branch August 30, 2026 23:13
@EVWorth EVWorth mentioned this pull request Sep 12, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant