Repository navigation
fix(grid): identify rows by the real key, before the edit not after (#387, #400) - #626
Merged
Merged
Conversation
A functional index — `UNIQUE KEY ((LOWER(a)))` — leaves COLUMN_NAME NULL in INFORMATION_SCHEMA.STATISTICS, with the expression in a separate column. `get_indexes` decoded that as `String`, so reading indexes for any table carrying one panicked with UnexpectedNullError and took down the schema read for the entire table, not just that row. EXPRESSION cannot be selected in its place: MariaDB has no such column and errors on the query (verified on 11.x). The index is now listed with no columns, which is the honest answer for something indexing an expression rather than a column, and callers that need identifying columns — the grid, resolving how to address a row — skip it naturally. Covered by a live-server regression test; it panics against the old code. Co-Authored-By: Claude Opus 5 <[email protected]>
Result-set metadata reports `is_primary_key` as false for every column, and always will: sqlx keeps MySQL's ColumnFlags `pub(crate)`, so the executor has nothing to populate it from. `getWhereColumns` read that metadata, found no key, and fell back to matching on every column — for every table, whether or not it had a key (#387, #400). Row identity now comes from the schema, in `useRowKey`, resolved when the result arrives rather than when Save is pressed. A warning that appears only after a failed save is a warning that came too late; the toolbar now says what is wrong while there is still time to change the query. Three things it does that the old check did not: - Falls back to a UNIQUE index over NOT NULL columns when there is no primary key, narrowest first. Nullable columns are excluded on purpose: UNIQUE does not constrain NULLs, and both MySQL 8 and MariaDB 11 accept two rows holding NULL there — verified. - Distinguishes "this table has no key" from "your query did not select it", which call for different responses from the user, and names the columns to add. - Treats a failed schema read as unknown rather than as no-key. Claiming there is no key is what invites the all-columns WHERE this exists to avoid. `getWhereColumns` and `getPrimaryKeyColumns` are removed rather than fixed — both read the metadata that cannot answer the question. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Sep 11, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
is_primary_keyis false on every result column and always will be — sqlx keeps MySQL'sColumnFlagspub(crate), so the executor has nothing to populate it from.getWhereColumnsread that metadata, found no key, and fell back to matching on every column — for every table, key or no key.Row identity now comes from the schema, in a new
useRowKeyhook, resolved when the result arrives rather than when Save is pressed. A warning that appears only after a failed save came too late; the toolbar now says what is wrong while there is still time to change the query.Beyond restoring the key:
getWhereColumnsandgetPrimaryKeyColumnsare removed rather than fixed — both read metadata that cannot answer the question.Also: a crash in the code this now depends on
A functional index (
UNIQUE KEY ((LOWER(a)))) leavesCOLUMN_NAMENULL inINFORMATION_SCHEMA.STATISTICS.get_indexesdecoded it asStringand panicked, failing the index read for the whole table.EXPRESSIONcannot be selected instead — MariaDB has no such column and errors on the query. The index is now listed with no columns, and callers needing identifying columns skip it naturally.Verification
useRowKeytests: 10, including mutation-checked (removing the nullable filter fails the right one)Closes #387
Closes #400
🤖 Generated with Claude Code