Skip to content

Commit

Permalink
/go/libraries/doltcore/{doltcore,sqle}: fix get database
Browse files Browse the repository at this point in the history
  • Loading branch information
coffeegoddd committed Oct 23, 2024
1 parent 953f8b1 commit 4ab1d6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
11 changes: 9 additions & 2 deletions go/libraries/doltcore/doltdb/system_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (

const (
// DoltNamespace is the name prefix of dolt system tables. We reserve all tables that begin with dolt_ for system use.
DoltNamespace = "dolt"
DoltNamespace = "dolt"
DoltCINamespace = DoltNamespace + "_ci"
)

var ErrSystemTableCannotBeModified = errors.New("system tables cannot be dropped or altered")
Expand All @@ -54,6 +55,12 @@ func HasDoltPrefix(s string) bool {
return strings.HasPrefix(strings.ToLower(s), DoltNamespace)
}

// HasDoltCIPrefix returns a boolean whether or not the provided string is prefixed with the DoltCINamespace. Users should
// not be able to create tables in this reserved namespace.
func HasDoltCIPrefix(s string) bool {
return strings.HasPrefix(strings.ToLower(s), DoltCINamespace)
}

// IsFullTextTable returns a boolean stating whether the given table is one of the pseudo-index tables used by Full-Text
// indexes.
// TODO: Schema name
Expand All @@ -67,7 +74,7 @@ func IsFullTextTable(name string) bool {

// IsDoltCITable returns whether the table name given is a dolt-ci table
func IsDoltCITable(name string) bool {
return HasDoltPrefix(name) && set.NewStrSet(writeableSystemTables).Contains(name) && !IsFullTextTable(name)
return HasDoltCIPrefix(name) && set.NewStrSet(writeableSystemTables).Contains(name) && !IsFullTextTable(name)
}

// IsReadOnlySystemTable returns whether the table name given is a system table that should not be included in command line
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 @@ -877,7 +877,7 @@ func (db Database) newDoltTable(tableName string, sch schema.Schema, tbl *doltdb
var table sql.Table
if doltdb.IsReadOnlySystemTable(tableName) {
table = readonlyTable
} else if doltdb.IsDoltCITable(tableName) {
} else if doltdb.IsDoltCITable(tableName) && !doltdb.IsFullTextTable(tableName) {
table = &AlterableDoltTable{WritableDoltTable{DoltTable: readonlyTable, db: db}}
} else if doltdb.HasDoltPrefix(tableName) && !doltdb.IsFullTextTable(tableName) {
table = &WritableDoltTable{DoltTable: readonlyTable, db: db}
Expand Down
5 changes: 0 additions & 5 deletions go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2052,8 +2052,3 @@ func TestDoltWorkspace(t *testing.T) {
harness := newDoltEnginetestHarness(t)
RunDoltWorkspaceTests(t, harness)
}

func TestDoltCIConfig(t *testing.T) {
h := newDoltEnginetestHarness(t)
RunDoltCIConfigTests(t, h)
}

0 comments on commit 4ab1d6c

Please sign in to comment.