Fix SQLite generated table column metadata - #581
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Previous Review Summaries (2 snapshots, latest commit 6087646)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 6087646)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous review (commit 4764730)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by step-3.7-flash · Input: 297.4K · Output: 43K · Cached: 7.1M |
debba
left a comment
There was a problem hiding this comment.
Thanks for looking into this, but I don't think this actually fixes #162.
The repro in the issue is a plain table with a generated column, no view involved. I tested against a real database (system SQLite 3.51 and the bundled 3.46 behave the same):
PRAGMA table_infoon the table only returnsudate, the generated column is missing.table_xinforeturns it (hidden=3for STORED,hidden=2for VIRTUAL). That mismatch between column metadata and theSELECT *data is exactly the grid misalignment in the issue's screenshot.- On a view over that table,
table_infoalready returns all the columns, same output astable_xinfo. Columns coming from generated columns are just ordinary view columns.
So the change in get_view_columns is a no-op for this bug. The functions the grid actually uses for tables, get_columns (src-tauri/src/drivers/sqlite/mod.rs:67) and get_all_columns_batch (mod.rs:160), still use table_info and are still broken.
The new test also passes without the fix: I reverted line 841 back to table_info, rebuilt, and test_get_view_columns_includes_generated_table_columns still passes. Note that the test command in the description uses --no-run, so it compiles the test but never runs it, which is probably how this slipped through.
For a proper fix I'd suggest:
- Switch
get_columnsandget_all_columns_batchtotable_xinfo. Keeping the view change is fine, it's harmless. - Be careful with writes: generated columns can't be inserted or updated, and
TableColumnhas nois_generatedflag, so exposing them in table metadata may let the row editor build INSERT/UPDATE statements that SQLite rejects. Thehiddenvalue fromtable_xinfo(2 = virtual, 3 = stored) is what you need to flag them. - The regression test should target
get_columnson the table itself, and should be verified to fail on main before the fix.
Happy to re-review once it's updated.
|
Updated this based on the review. Changes made:
Validation:
The Rust test compiles locally. Direct execution on my Windows environment exits before the harness runs with |
|
Updated this with additional backend regression coverage for the write-path concern from the review. Changes made:
Validation:
Direct Rust test execution still exits before the harness starts on my Windows environment with |
|
Thanks a lot for this one! I reviewed it locally and tested against a db with both STORED and VIRTUAL generated columns: metadata comes through correctly, the grid finally shows the computed values and the write paths reject them as expected. The two new Rust tests also pass fine here on Linux, so the STATUS_ENTRYPOINT_NOT_FOUND thing was just your local Windows setup. One small follow-up we can handle separately: table_xinfo also returns hidden columns of virtual tables (hidden=1, e.g. the docs/rank columns of fts5 tables), which now show up in the new row modal as editable fields. Filtering those rows out would restore the old behavior there. Great work, merging now. |
debba
left a comment
There was a problem hiding this comment.
All the points from my previous review are addressed now, and I verified the new tests actually run and pass this time. Approving.
Summary
Testing
Note: the targeted Rust test compiles locally, but direct execution on this Windows environment exits before the harness runs with STATUS_ENTRYPOINT_NOT_FOUND.
Fixes #162