Skip to content

Commit

Permalink
merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cor committed Jan 4, 2024
2 parents 1a9b85d + fcc1779 commit 6a4e7dd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go/cmd/dolt/dolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import (
)

const (
Version = "1.30.4"
Version = "1.30.5"
)

var dumpDocsCommand = &commands.DumpDocsCmd{}
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ func (db Database) LoadRebasePlan(ctx *sql.Context) (*rebase.RebasePlan, error)

// SaveRebasePlan implements the rebase.RebasePlanDatabase interface
func (db Database) SaveRebasePlan(ctx *sql.Context, plan *rebase.RebasePlan) error {
pkSchema := sql.NewPrimaryKeySchema(dprocedures.DoltRebaseSystemTableSchema, 2)
pkSchema := sql.NewPrimaryKeySchema(dprocedures.DoltRebaseSystemTableSchema)
// we use createSqlTable, instead of CreateTable to avoid the "dolt_" reserved prefix table name check
err := db.createSqlTable(ctx, doltdb.RebaseTableName, pkSchema, sql.Collation_Default)
if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions go/libraries/doltcore/sqle/dprocedures/dolt_rebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ var RebaseActionEnumType = types.MustCreateEnumType([]string{

var DoltRebaseSystemTableSchema = []*sql.Column{
{
Name: "rebase_order",
Type: types.MustCreateDecimalType(6, 2),
Nullable: false,
Name: "rebase_order",
Type: types.MustCreateDecimalType(6, 2),
Nullable: false,
PrimaryKey: true,
},
{
Name: "action",
Expand Down Expand Up @@ -247,6 +248,10 @@ func startRebase(ctx *sql.Context, upstreamPoint string) error {
// Create the rebase plan and save it in the database
rebasePlan, err := rebase.CreateDefaultRebasePlan(ctx, startCommit, upstreamCommit)
if err != nil {
abortErr := abortRebase(ctx)
if abortErr != nil {
return fmt.Errorf("%s: unable to cleanly abort rebase: %s", err.Error(), abortErr.Error())
}
return err
}
rdb, ok := db.(rebase.RebasePlanDatabase)
Expand Down
49 changes: 49 additions & 0 deletions go/libraries/doltcore/sqle/enginetest/dolt_queries_rebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ var DoltRebaseScriptTests = []queries.ScriptTest{
"adjust the rebase plan in the dolt_rebase table, then " +
"continue rebasing by calling dolt_rebase('--continue')"}},
},
{
Query: "update dolt_rebase set rebase_order=1.0 where rebase_order=2.0;",
ExpectedErrStr: "duplicate primary key given: [1]",
},
{
Query: "update dolt_rebase set action='squash';",
Expected: []sql.Row{{gmstypes.OkResult{
Expand Down Expand Up @@ -235,6 +239,51 @@ var DoltRebaseScriptTests = []queries.ScriptTest{
},
},
},
{
Name: "dolt_rebase: no commits to rebase",
SetUpScript: []string{
"create table t (pk int primary key);",
"call dolt_commit('-Am', 'creating table t');",
"call dolt_branch('branch1');",

"insert into t values (0);",
"call dolt_commit('-am', 'inserting row 0');",

"call dolt_checkout('branch1');",
"insert into t values (1);",
"call dolt_commit('-am', 'inserting row 1');",
"insert into t values (10);",
"call dolt_commit('-am', 'inserting row 10');",
"insert into t values (100);",
"call dolt_commit('-am', 'inserting row 100');",
"insert into t values (1000);",
"call dolt_commit('-am', 'inserting row 1000');",
"insert into t values (10000);",
"call dolt_commit('-am', 'inserting row 10000');",
"insert into t values (100000);",
"call dolt_commit('-am', 'inserting row 100000');",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "select active_branch();",
Expected: []sql.Row{{"branch1"}},
},
{
Query: "call dolt_rebase('-i', 'HEAD');",
ExpectedErrStr: "didn't identify any commits!",
},
{
// if the rebase doesn't start, then we should remain on the original branch
Query: "select active_branch();",
Expected: []sql.Row{{"branch1"}},
},
{
// and the rebase working branch shouldn't be present
Query: "select * from dolt_branches where name='dolt_rebase_branch1';",
Expected: []sql.Row{},
},
},
},
{
Name: "dolt_rebase: abort properly cleans up",
SetUpScript: []string{
Expand Down

0 comments on commit 6a4e7dd

Please sign in to comment.