diff --git a/go/cmd/dolt/commands/commit.go b/go/cmd/dolt/commands/commit.go index 4e46971821..9e485d4ffa 100644 --- a/go/cmd/dolt/commands/commit.go +++ b/go/cmd/dolt/commands/commit.go @@ -121,11 +121,11 @@ func performCommit(ctx context.Context, commandStr string, args []string, cliCtx defer closeFunc() } - // cliCtx always uses the session start as its time. We want the current time, - // which is stored in ctx. - /*if c, ok := ctx.(*sql.Context); ok { + // TODO: This is not a nice solution. Currently, the cliCtx parameter's sqlCtx that we get from QueryEngine() is never refreshed. + // TODO: It would be ideal to have it generate/regenerate it's sqlCtx more often, as it likely has impacts beyond just the time. + if c, ok := ctx.(*sql.Context); ok { sqlCtx.SetQueryTime(c.QueryTime()) - }*/ + } // dolt_commit performs this check as well. This nips the problem in the bud early, but is not required. err = branch_control.CheckAccess(sqlCtx, branch_control.Permissions_Write) diff --git a/integration-tests/bats/sql-shell-commit-time.expect b/integration-tests/bats/sql-shell-commit-time.expect index 4fcdda2bbb..035d7c13a2 100755 --- a/integration-tests/bats/sql-shell-commit-time.expect +++ b/integration-tests/bats/sql-shell-commit-time.expect @@ -2,25 +2,42 @@ set timeout 5 set env(NO_COLOR) 1 -exp_internal 1 source "$env(BATS_CWD)/helper/common_expect_functions.tcl" spawn dolt sql +set first_commit_date "" +set second_commit_date "" + expect_with_defaults {dolt-repo-[0-9]+/main\*> } { send "\\commit -A -m \"created a table\"\r"; } -expect_with_defaults {Date:\s+(.+)} { set first_commit_date $expect_out(1,string) } +expect_with_defaults {Date:\s+([^\r]+)} { + global first_commit_date + set first_commit_date $expect_out(1,string) +} expect_with_defaults {dolt-repo-[0-9]+/main> } { send "insert into test (pk) values (1);\r"; } -after 1000 # We want to check for different timestamps, so we wait a second to ensure that. +# We want to check for different timestamps, so we wait a second to ensure that. +after 2000 expect_with_defaults {dolt-repo-[0-9]+/main> } { send "\\commit -A -m \"added a row\"\r"; } -expect_with_defaults {Date:\s+(.+)} { set second_commit_date $expect_out(1, string)} +expect_with_defaults {Date:\s+([^\r]+)} { + global second_commit_date + set second_commit_date $expect_out(1,string) +} -expect_with_defaults_2 {Date:\s+(.+)} {dolt-repo-[0-9]+/main> } { send "quit\r" } +#if { $first_commit_date eq $second_commit_date } { + #puts "Test failure: commit time stamps did not differ" + #exit 1 +#} + +puts "\r\r------------------------\r\r" +puts "Compared $first_commit_date to $second_commit_date" +puts "\r\r------------------------\r\r" +expect_with_defaults {dolt-repo-[0-9]+/main> } { send "quit\r" } expect eof exit \ No newline at end of file diff --git a/integration-tests/bats/sql-shell.bats b/integration-tests/bats/sql-shell.bats index 69813fc80d..1d755a24d6 100644 --- a/integration-tests/bats/sql-shell.bats +++ b/integration-tests/bats/sql-shell.bats @@ -1034,9 +1034,7 @@ expect eof # bats test_tags=no_lambda @test "sql-shell: commit time set correctly in shell" { skiponwindows "Need to install expect and make this script work on windows." + run $BATS_TEST_DIRNAME/sql-shell-commit-time.expect - - echo "$output" - [ "$status" -eq 0 ] } \ No newline at end of file