Summary
Staging an individual workspace row via UPDATE dolt_workspace_<table> SET staged = TRUE WHERE ... — the SQL git add -p flow added in 0.11.7 (PR dolthub/doltlite#1211, https://www.dolthub.com/blog/2024-09-10-dolt-add--patch/) — works on a table with no secondary index, but throws on any table that has one or more secondary indexes (plain or unique):
Error: run: staging individual workspace rows for indexed tables is not yet supported
This makes row-level staging unusable on any real-world schema, since production tables almost always carry secondary indexes.
Version
@dolthub/doltlite@0.11.9 (Node binding). macOS (arm64).
Minimal repro
const { DatabaseSync } = require('@dolthub/doltlite')
function tryStage(label, createSql) {
const db = new DatabaseSync(':memory:')
db.exec(createSql)
db.doltAdd(); db.doltCommit('schema')
db.exec("INSERT INTO t VALUES ('a','x'),('b','y')")
try {
db.exec("UPDATE dolt_workspace_t SET staged = TRUE WHERE to_id = 'a'")
console.log(label, '=> OK')
} catch (e) {
console.log(label, '=> THREW:', e.message)
}
db.close()
}
tryStage('no secondary index ', "CREATE TABLE t (id TEXT PRIMARY KEY, v TEXT)")
tryStage('plain index ', "CREATE TABLE t (id TEXT PRIMARY KEY, v TEXT); CREATE INDEX ix ON t(v)")
tryStage('unique index ', "CREATE TABLE t (id TEXT PRIMARY KEY, v TEXT); CREATE UNIQUE INDEX uq ON t(v)")
Output:
no secondary index => OK
plain index => THREW: staging individual workspace rows for indexed tables is not yet supported
unique index => THREW: staging individual workspace rows for indexed tables is not yet supported
Expected
UPDATE dolt_workspace_<table> SET staged = TRUE WHERE <pk match> stages only the matching row, regardless of whether the table has secondary indexes — same as it does for an index-free table. The subsequent SELECT dolt_commit('-m', ...) should then commit only the staged row(s).
Actual
The UPDATE on dolt_workspace_<table> throws staging individual workspace rows for indexed tables is not yet supported the moment the table has any secondary index. Table-level staging (doltAdd('<table>') / SELECT dolt_add('<table>')) is unaffected and works on indexed tables; only the per-row workspace flow is blocked.
Impact
The row-level git add -p equivalent is the headline of the workspace-table flow, but it's currently limited to tables with no secondary index. For any application using indexed tables (i.e. essentially all of them) the feature can't be used, leaving table-level staging as the only available granularity.
Happy to test a fix against the repro above.
Summary
Staging an individual workspace row via
UPDATE dolt_workspace_<table> SET staged = TRUE WHERE ...— the SQLgit add -pflow added in 0.11.7 (PR dolthub/doltlite#1211, https://www.dolthub.com/blog/2024-09-10-dolt-add--patch/) — works on a table with no secondary index, but throws on any table that has one or more secondary indexes (plain or unique):This makes row-level staging unusable on any real-world schema, since production tables almost always carry secondary indexes.
Version
@dolthub/doltlite@0.11.9(Node binding). macOS (arm64).Minimal repro
Output:
Expected
UPDATE dolt_workspace_<table> SET staged = TRUE WHERE <pk match>stages only the matching row, regardless of whether the table has secondary indexes — same as it does for an index-free table. The subsequentSELECT dolt_commit('-m', ...)should then commit only the staged row(s).Actual
The
UPDATEondolt_workspace_<table>throwsstaging individual workspace rows for indexed tables is not yet supportedthe moment the table has any secondary index. Table-level staging (doltAdd('<table>')/SELECT dolt_add('<table>')) is unaffected and works on indexed tables; only the per-row workspace flow is blocked.Impact
The row-level
git add -pequivalent is the headline of the workspace-table flow, but it's currently limited to tables with no secondary index. For any application using indexed tables (i.e. essentially all of them) the feature can't be used, leaving table-level staging as the only available granularity.Happy to test a fix against the repro above.