fix(sqle): fix status table bugs and refactor redundant row struct

Fix bugs introduced in initial dolt_status_ignored implementation commit
and refactor to eliminate duplicate code between status tables.

fixes:
- Fix schema conflict status incorrectly set to "merged" instead
of "schema conflict" in getStatusRowsData
- Add dolt_status_ignored to expected system tables list in
DOLT_SHOW_SYSTEM_TABLES test (should fix existing test failures)

Refs: #5862
This commit is contained in:
David Dansby
2025-12-18 22:28:30 -08:00
parent 00f459df84
commit 33a13363a2
2 changed files with 13 additions and 30 deletions

View File

@@ -115,13 +115,6 @@ type statusTableRow struct {
// of this table when you are using local vs remote sql connections.
}
// statusRowData contains the data for a single status row.
type statusRowData struct {
tableName string
status string
isStaged byte
}
// containsTableName checks if a table name is in the list of table names.
func containsTableName(name string, names []doltdb.TableName) bool {
for _, s := range names {
@@ -139,7 +132,7 @@ func getStatusRowsData(
ctx *sql.Context,
rp env.RootsProvider[*sql.Context],
ws *doltdb.WorkingSet,
) ([]statusRowData, []diff.TableDelta, error) {
) ([]statusTableRow, []diff.TableDelta, error) {
if rp == nil {
return nil, nil, nil
}
@@ -173,7 +166,7 @@ func getStatusRowsData(
return nil, nil, err
}
rows := make([]statusRowData, 0, len(stagedTables)+len(unstagedTables)+len(stagedSchemas)+len(unstagedSchemas))
rows := make([]statusTableRow, 0, len(stagedTables)+len(unstagedTables)+len(stagedSchemas)+len(unstagedSchemas))
cvTables, err := doltdb.TablesWithConstraintViolations(ctx, roots.Working)
if err != nil {
@@ -181,7 +174,7 @@ func getStatusRowsData(
}
for _, tbl := range cvTables {
rows = append(rows, statusRowData{
rows = append(rows, statusTableRow{
tableName: tbl.String(),
status: "constraint violation",
})
@@ -190,15 +183,15 @@ func getStatusRowsData(
if ws.MergeActive() {
ms := ws.MergeState()
for _, tbl := range ms.TablesWithSchemaConflicts() {
rows = append(rows, statusRowData{
rows = append(rows, statusTableRow{
tableName: tbl.String(),
isStaged: byte(0),
status: mergedStatus,
status: "schema conflict",
})
}
for _, tbl := range ms.MergedTables() {
rows = append(rows, statusRowData{
rows = append(rows, statusTableRow{
tableName: tbl.String(),
isStaged: byte(1),
status: mergedStatus,
@@ -211,7 +204,7 @@ func getStatusRowsData(
return nil, nil, err
}
for _, tbl := range cnfTables {
rows = append(rows, statusRowData{
rows = append(rows, statusTableRow{
tableName: tbl.String(),
status: mergeConflictStatus,
})
@@ -225,7 +218,7 @@ func getStatusRowsData(
if containsTableName(tblName, cvTables) {
continue
}
rows = append(rows, statusRowData{
rows = append(rows, statusTableRow{
tableName: tblName,
isStaged: byte(1),
status: statusString(td),
@@ -240,7 +233,7 @@ func getStatusRowsData(
if containsTableName(tblName, cvTables) {
continue
}
rows = append(rows, statusRowData{
rows = append(rows, statusTableRow{
tableName: tblName,
isStaged: byte(0),
status: statusString(td),
@@ -248,7 +241,7 @@ func getStatusRowsData(
}
for _, sd := range stagedSchemas {
rows = append(rows, statusRowData{
rows = append(rows, statusTableRow{
tableName: sd.CurName(),
isStaged: byte(1),
status: schemaStatusString(sd),
@@ -256,7 +249,7 @@ func getStatusRowsData(
}
for _, sd := range unstagedSchemas {
rows = append(rows, statusRowData{
rows = append(rows, statusTableRow{
tableName: sd.CurName(),
isStaged: byte(0),
status: schemaStatusString(sd),
@@ -272,22 +265,11 @@ func newStatusItr(ctx *sql.Context, st *StatusTable) (*StatusItr, error) {
return &StatusItr{rows: nil}, nil
}
// Get status data using the shared function
statusRows, _, err := getStatusRowsData(ctx, st.rootsProvider, st.workingSet)
rows, _, err := getStatusRowsData(ctx, st.rootsProvider, st.workingSet)
if err != nil {
return nil, err
}
// Convert statusRowData to statusTableRow
rows := make([]statusTableRow, len(statusRows))
for i, row := range statusRows {
rows[i] = statusTableRow{
tableName: row.tableName,
isStaged: row.isStaged,
status: row.status,
}
}
return &StatusItr{rows: rows}, nil
}

View File

@@ -8670,6 +8670,7 @@ var DoltSystemVariables = []queries.ScriptTest{
{"dolt_remotes"},
{"dolt_stashes"},
{"dolt_status"},
{"dolt_status_ignored"},
{"dolt_workspace_test"},
{"test"},
},