Skip to content

Commit

Permalink
Fix windows file paths for dropping databases (#7494)
Browse files Browse the repository at this point in the history
  • Loading branch information
jycor authored Feb 14, 2024
1 parent 3483a08 commit 4849f99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion go/libraries/doltcore/sqle/database_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"errors"
"fmt"
"path/filepath"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -589,7 +590,7 @@ func (p *DoltDatabaseProvider) DropDatabase(ctx *sql.Context, name string) error
}

// If this database is re-created, we don't want to return any cached results.
err = dbfactory.DeleteFromSingletonCache(dropDbLoc + "/.dolt/noms")
err = dbfactory.DeleteFromSingletonCache(filepath.ToSlash(dropDbLoc + "/.dolt/noms"))
if err != nil {
return err
}
Expand Down
19 changes: 11 additions & 8 deletions integration-tests/bats/sql-create-database.bats
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ SQL
}

@test "sql-create-database: drop database" {
skiponwindows "failing with file in use error"

dolt sql <<SQL
create database mydb;
use mydb;
Expand All @@ -99,6 +97,17 @@ SQL
[ ! -d mydb ]
}

@test "sql-create-database: drop and recreate database" {
run dolt sql <<SQL
create database mydb;
drop database mydb;
create database mydb;
SQL

[ "$status" -eq 0 ]
[ -d mydb ]
}

@test "sql-create-database: with data-dir" {
skiponwindows "failing with file in use error"

Expand Down Expand Up @@ -195,8 +204,6 @@ SQL
}

@test "sql-create-database: create and drop new database in same session" {
skiponwindows "failing with file in use error"

run dolt sql << SQL
CREATE DATABASE mydb;
DROP DATABASE mydb;
Expand All @@ -211,8 +218,6 @@ SQL
}

@test "sql-create-database: create new database IF NOT EXISTS" {
skiponwindows "failing with file in use error"

# Test bad syntax.
run dolt sql -q "CREATE DATABASE IF EXISTS test;"
[ "$status" -eq 1 ]
Expand Down Expand Up @@ -290,8 +295,6 @@ SQL
}

@test "sql-create-database: SHOW DATABASES works after CREATE and DROP" {
skiponwindows "failing with file in use error"

run dolt sql -q "SHOW DATABASES"
before=$output

Expand Down

0 comments on commit 4849f99

Please sign in to comment.