[Bug]: MySQL JSON column values shown as NULL in data grid#107
[Bug]: MySQL JSON column values shown as NULL in data grid#107debba merged 2 commits intodebba:mainfrom
Conversation
MySQL JSON columns were not being decoded properly because `extract_value` lacked a dedicated JSON branch. Unlike PostgreSQL which already handles `serde_json::Value`, the MySQL driver fell through every `try_get` attempt and returned `Null`. - Enable the sqlx `json` feature so `Decode<MySql>` is implemented for `serde_json::Value` - Add an explicit JSON type branch in `mysql/extract.rs` that first tries `try_get::<serde_json::Value>`, then falls back to raw-byte decoding and manual JSON parsing Made-with: Cursor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (8 files)
Notes:
Reviewed by kimi-k2.5-0127 · 115,816 tokens |
JSON columns in the sidebar row editor previously displayed "[object Object]" and were not editable. This adds a dedicated JsonInput component with real-time validation, pretty-print formatting, and proper read/write support for JSON values. - Add `src/utils/json.ts` with isJsonColumn, formatJsonForEditor, validateJson, and parseJsonEditorValue helpers - Add `src/components/ui/JsonInput.tsx` — textarea-based JSON editor with format button and valid/invalid indicator - Wire JsonInput into FieldEditor for JSON/JSONB columns - DataGrid: double-click on JSON cells opens sidebar editor - Backend: update_record and insert_record now accept Object/Array values via CAST(? AS JSON) instead of rejecting them - Add i18n keys for en, zh, it, es Made-with: Cursor
|
Hi! Are you already working on it? |
|
Hi @debba, thanks for testing! I verified the fix works correctly on MySQL 8.0.42. The The key difference is likely the MySQL variant you're testing on:
Could you confirm which database you're testing on? You can check with My test environment:
CREATE TABLE `tapp_appointment_recommend_rule_limit` (
`id` int NOT NULL AUTO_INCREMENT,
`limit_type` tinyint NOT NULL,
`limit_info` json NOT NULL,
`delete_flag` tinyint NOT NULL DEFAULT 0,
`rule_id` int NOT NULL,
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
); |
|
Sorry, you're right. |

Summary
JSONtype columns displaynullin the data grid even when they contain valid JSON data[object Object]and cannot be editedextract_valueinmysql/extract.rshas no dedicated JSON branch — unlike the PostgreSQL driver which explicitly handlesserde_json::Value, the MySQL driver falls through alltry_getattempts and hits the fallbackNullreturnupdate_recordandinsert_recordrejectObject/Arrayvalues with "Unsupported Value type" errorChanges
Backend (Rust)
src-tauri/Cargo.toml: add"json"to sqlx features — this registersDecode<MySql>forserde_json::Valuesrc-tauri/src/drivers/mysql/extract.rs: add acol_type == "JSON"branch before the GEOMETRY block, mirroring the PostgreSQL approach with an additional raw-byte fallback for edge casessrc-tauri/src/drivers/mysql/mod.rs: handleObject/Arrayvalues inupdate_recordandinsert_recordviaCAST(? AS JSON)instead of returning an errorFrontend (React/TypeScript)
src/utils/json.ts(new):isJsonColumn,formatJsonForEditor,validateJson,parseJsonEditorValueutility functionssrc/components/ui/JsonInput.tsx(new): dedicated JSON editor component with:src/components/ui/FieldEditor.tsx: wireJsonInputfor JSON/JSONB column types in the sidebar editorsrc/components/ui/DataGrid.tsx: double-click on JSON cells opens the sidebar editor instead of inline editingsrc/i18n/locales/{en,zh,it,es}.json: addjsonInputtranslation keysTest plan
JSONcolumnnull)NULLJSON values still display asnull