You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P0] [bug] is_primary_key hardcoded false — UPDATE WHERE silently breaks on NULLable columns #387
[P0] [bug] is_primary_key hardcoded false for every column — UPDATE WHERE falls back to all columns
Context
The results grid lets users edit cell values and click Save to generate UPDATE/INSERT/DELETE statements. The WHERE clause for UPDATEs/DELETEs relies on getWhereColumns(columns) which uses is_primary_key to decide which columns to match. But the backend hardcodes is_primary_key: false in build_select_result, so the frontend sees every column as non-PK and falls back to matching against all columns — fragile against NULLable data and changes to other columns.
Problem
Per docs/audits/results.md F1.
Concrete failure: a row with email=NULL cannot match WHERE email = '[email protected]' (NULL is never = anything in SQL). MySQL returns rows_affected: 0 and the user sees "Applied 1 change(s)" with no data actually changed. The EditToolbar's "No primary key detected" warning is always shown even for tables with a real PK.
Static analysis only. Repro: run any UPDATE save against a table with a NULLable column — observe 0 rows updated despite "Applied" toast.
Expected
build_select_result populates is_primary_key correctly; getWhereColumns returns the PK; the EditToolbar doesn't show the false warning.
Proposed fix
Scope M. Read PK info from SHOW COLUMNS FROM \db`.`table`(one round-trip per result set, cached per connection) orINFORMATION_SCHEMA.COLUMNSjoined on schema/table/column. Pass throughColumnMeta.is_primary_key`.
Acceptance
A SELECT * FROM users WHERE id = 1 renders the EditToolbar WITHOUT the PK warning; handleSave produces UPDATE \users` SET `name`='x' WHERE `id`=1 LIMIT 1`.
Scoping note — this is not fixed by #529, despite being referenced there.
#529 worked around it in the frontend: the grid now asks the schema inspector (api.getColumns, reading information_schema) for the real primary key and addresses rows by it, refusing the save when the key is not among the selected columns.
MySQL does send NOT_NULL and PRIMARY_KEY in the column definition packet, but sqlx keeps ColumnFlagspub(crate), so the result-building code cannot read them. Both fields are placeholders, and the code carries a comment saying not to start trusting them.
Remaining work is one of: get ColumnFlags exposed upstream in sqlx, decode the column-definition packet ourselves, or drop the two fields from ColumnMeta entirely so nothing can be tempted to read them. The third is the cheapest and matches how the data is actually sourced today.
Activity
fix(grid): write edits to the right table, addressed by the real key (#…
EVWorth commentedon Sep 4, 2026
Scoping note — this is not fixed by #529, despite being referenced there.
#529 worked around it in the frontend: the grid now asks the schema inspector (
api.getColumns, readinginformation_schema) for the real primary key and addresses rows by it, refusing the save when the key is not among the selected columns.The defect this issue names is still present in Rust. src-tauri/crates/mas-core/src/query/executor.rs still builds every
ColumnMetawith:MySQL does send
NOT_NULLandPRIMARY_KEYin the column definition packet, but sqlx keepsColumnFlagspub(crate), so the result-building code cannot read them. Both fields are placeholders, and the code carries a comment saying not to start trusting them.Remaining work is one of: get
ColumnFlagsexposed upstream in sqlx, decode the column-definition packet ourselves, or drop the two fields fromColumnMetaentirely so nothing can be tempted to read them. The third is the cheapest and matches how the data is actually sourced today.Leaving open.
fix(grid): identify rows by the real key, before the edit not after (#…
feat(grid): select rows, and copy them in the formats people paste into
feat(grid): select rows, and copy them in the formats people paste in…