Skip to content

Commit

Permalink
set config variable before server starts
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifersp committed Nov 14, 2023
1 parent 0ee7bac commit c676ac2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/engine/sqlengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func NewSqlEngine(
}

b := env.GetDefaultInitBranch(mrEnv.Config())
pro, err := dsqle.NewDoltDatabaseProviderWithDatabases(b, mrEnv.FileSystem(), all, locations, mrEnv.Config().GetStringOrDefault(env.DisableHyphenInDatabaseName, "false") == "true")
pro, err := dsqle.NewDoltDatabaseProviderWithDatabases(b, mrEnv.FileSystem(), all, locations, env.DisableHyphenInDBName(mrEnv.Config()))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/filter-branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func rebaseSqlEngine(ctx context.Context, dEnv *env.DoltEnv, cm *doltdb.Commit)
}

b := env.GetDefaultInitBranch(dEnv.Config)
pro, err := dsqle.NewDoltDatabaseProviderWithDatabase(b, mrEnv.FileSystem(), db, dEnv.FS, env.DisableHyphenInDBName(mrEnv.Config()))
pro, err := dsqle.NewDoltDatabaseProviderWithDatabase(b, mrEnv.FileSystem(), db, dEnv.FS, env.DisableHyphenInDBName(dEnv.Config))
if err != nil {
return nil, nil, err
}
Expand Down
12 changes: 10 additions & 2 deletions integration-tests/bats/undrop.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ setup() {
# sql-server starts.
mkdir ' drop- me-2 ' && cd ' drop- me-2 '
dolt init && cd ..
setup_remote_server
}

teardown() {
Expand All @@ -21,6 +20,7 @@ teardown() {
}

@test "undrop: undrop error messages" {
setup_remote_server
# When called without any argument, dolt_undrop() returns an error
# that includes the database names that can be undropped.
run dolt sql -q "CALL dolt_undrop();"
Expand Down Expand Up @@ -52,18 +52,20 @@ teardown() {
}

@test "undrop: purge error messages" {
setup_remote_server
# Assert that specifying args when calling dolt_purge_dropped_databases() returns an error
run dolt sql -q "call dolt_purge_dropped_databases('all', 'of', 'the', 'dbs');"
[ $status -eq 1 ]
[[ $output =~ "dolt_purge_dropped_databases does not take any arguments" ]] || false
}

@test "undrop: undrop root database with hyphen replaced in its name" {
dolt config --global --add database.disableHyphen true
setup_remote_server
# Create a new Dolt database directory to use as a root database
# NOTE: We use hyphens here to test how db dirs are renamed.
mkdir ' test- db-1 ' && cd ' test- db-1 '
dolt init
dolt config --add database.disableHyphen true
# Create some data and a commit in the database
dolt sql << EOF
create table t1 (pk int primary key, c1 varchar(200));
Expand Down Expand Up @@ -95,6 +97,7 @@ EOF
}

@test "undrop: undrop root database with hyphen allowed in its name" {
setup_remote_server
# Create a new Dolt database directory to use as a root database
# NOTE: We use hyphens here to test how db dirs are renamed.
mkdir ' test- db-1 ' && cd ' test- db-1 '
Expand Down Expand Up @@ -134,6 +137,7 @@ EOF
# the case of the database name given to dolt_undrop() doesn't match match the original case.
@test "undrop: undrop non-root database with hyphen replaced in its name" {
dolt config --add database.disableHyphen true
setup_remote_server
dolt sql << EOF
use drop_me_2;
create table t1 (pk int primary key, c1 varchar(200));
Expand Down Expand Up @@ -164,6 +168,7 @@ EOF
# Asserts that a non-root database can be dropped and then restored with dolt_undrop(), even when
# the case of the database name given to dolt_undrop() doesn't match match the original case.
@test "undrop: undrop non-root database with hyphen allowed in its name" {
setup_remote_server
dolt sql << EOF
use \`drop-_me-2\`;
create table t1 (pk int primary key, c1 varchar(200));
Expand Down Expand Up @@ -195,6 +200,7 @@ EOF
# with the same name and dropped, dolt_undrop will undrop the most
# recent database with that name.
@test "undrop: drop database, recreate, and drop again" {
setup_remote_server
# Create a database named test123
dolt sql << EOF
create database test123;
Expand Down Expand Up @@ -237,6 +243,7 @@ EOF
# TODO: In the future, it might be useful to allow dolt_undrop() to rename the dropped database to
# a new name, but for now, keep it simple and just disallow restoring in this case.
@test "undrop: undrop conflict" {
setup_remote_server
dolt sql << EOF
create database dAtAbAsE1;
use dAtAbAsE1;
Expand Down Expand Up @@ -274,6 +281,7 @@ EOF
}

@test "undrop: purging dropped databases" {
setup_remote_server
# Create a database to keep and a database to purge
dolt sql << EOF
create database keepme;
Expand Down

0 comments on commit c676ac2

Please sign in to comment.