From 4ab1d6caf2ea86290aa10c6ef6c90af6d13ebad9 Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Wed, 23 Oct 2024 11:28:18 -0700 Subject: [PATCH] /go/libraries/doltcore/{doltcore,sqle}: fix get database --- go/libraries/doltcore/doltdb/system_table.go | 11 +++++++++-- go/libraries/doltcore/sqle/database.go | 2 +- .../doltcore/sqle/enginetest/dolt_engine_test.go | 5 ----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/go/libraries/doltcore/doltdb/system_table.go b/go/libraries/doltcore/doltdb/system_table.go index 8555a9ea7f..e8af44a864 100644 --- a/go/libraries/doltcore/doltdb/system_table.go +++ b/go/libraries/doltcore/doltdb/system_table.go @@ -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") @@ -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 @@ -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 diff --git a/go/libraries/doltcore/sqle/database.go b/go/libraries/doltcore/sqle/database.go index 51d314ba92..bdcb195f8a 100644 --- a/go/libraries/doltcore/sqle/database.go +++ b/go/libraries/doltcore/sqle/database.go @@ -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} diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go b/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go index 248c98ce49..7880599883 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go @@ -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) -}