Merged github branch

This commit is contained in:
Tim Sehn
2025-06-17 13:28:54 -07:00
3 changed files with 24 additions and 8 deletions

View File

@@ -333,10 +333,11 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
// at runtime
switch {
case lwrName == doltdb.DoltDiffTablePrefix+doltdb.SchemasTableName:
// dolt_diff_dolt_schemas should work like other dolt_diff_ tables:
// showing the complete history of all schema changes across commits,
// plus any current working/staged changes
// Special handling for dolt_diff_dolt_schemas
// For schema diff tables, we want to show differences between HEAD and WORKING
// (or HEAD and STAGED), similar to how regular diff tables work
// Get the HEAD commit
if head == nil {
var err error
head, err = ds.GetHeadCommit(ctx, db.RevisionQualifiedName())
@@ -345,6 +346,18 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
}
}
// Get the HEAD commit hash and root
headHash, err := head.HashOf()
if err != nil {
return nil, false, err
}
headCommitHash := headHash.String()
headRoot, err := head.GetRootValue(ctx)
if err != nil {
return nil, false, err
}
// Use the same pattern as regular diff tables - this will show complete history
return NewDoltSchemasDiffTableWithHistory(ctx, db.ddb, head, root, db), true, nil

View File

@@ -374,15 +374,15 @@ func (dsdri *doltSchemasDiffRowIter) createDiffRow(toRow, fromRow sql.Row, diffT
// FROM columns (indices 7-13)
if fromRow != nil && len(fromRow) >= 5 {
copy(row[7:12], fromRow[0:5]) // from_type, from_name, from_fragment, from_extra, from_sql_mode
row[12] = dsdri.fromRef // from_commit
copy(row[7:12], fromRow[0:5]) // from_type, from_name, from_fragment, from_extra, from_sql_mode
row[12] = dsdri.fromRef // from_commit
row[13] = dsdri.getFromCommitDate() // from_commit_date from actual commit
} else {
// from_* schema columns are null for added rows, but commit info should be populated
for i := 7; i < 12; i++ {
row[i] = nil
}
row[12] = dsdri.fromRef // from_commit should always be populated (actual commit hash)
row[12] = dsdri.fromRef // from_commit should always be populated (actual commit hash)
row[13] = dsdri.getFromCommitDate() // from_commit_date from actual commit
}

View File

@@ -194,7 +194,10 @@ func doltSchemasDiffTableTests() []doltSchemasTableTest {
name: "check complete history is shown",
query: "SELECT COUNT(*) FROM dolt_diff_dolt_schemas",
rows: []sql.Row{
{int64(6)}, // Complete history: initial creation (2) + working changes (4) = 6 total changes
{"event", "new_event", "added"},
{"view", "new_view", "added"},
{"view", "original_view", "modified"}, // HEAD vs WORKING: shows proper diff types
{nil, nil, "removed"}, // removed trigger has NULL to_ values
},
},
{