diff --git a/go/libraries/doltcore/doltdb/system_table.go b/go/libraries/doltcore/doltdb/system_table.go index 336f0ec4ce..833db9ec75 100644 --- a/go/libraries/doltcore/doltdb/system_table.go +++ b/go/libraries/doltcore/doltdb/system_table.go @@ -20,6 +20,8 @@ import ( "sort" "strings" + "github.com/dolthub/dolt/go/libraries/doltcore/schema/typeinfo" + "github.com/dolthub/dolt/go/libraries/doltcore/schema" "github.com/dolthub/dolt/go/libraries/utils/funcitr" "github.com/dolthub/dolt/go/libraries/utils/set" @@ -33,6 +35,25 @@ const ( var ErrSystemTableCannotBeModified = errors.New("system tables cannot be dropped or altered") +var OldDocsSchema = schema.MustSchemaFromCols(schema.NewColCollection( + schema.NewColumn(DocPkColumnName, schema.DocNameTag, types.StringKind, true, schema.NotNullConstraint{}), + schema.NewColumn(DocTextColumnName, schema.DocTextTag, types.StringKind, false), +)) + +var DocsSchema schema.Schema + +func init() { + docTextCol, err := schema.NewColumnWithTypeInfo(DocTextColumnName, schema.DocTextTag, typeinfo.LongTextType, false, "", false, "") + if err != nil { + panic(err) + } + doltDocsColumns := schema.NewColCollection( + schema.NewColumn(DocPkColumnName, schema.DocNameTag, types.StringKind, true, schema.NotNullConstraint{}), + docTextCol, + ) + DocsSchema = schema.MustSchemaFromCols(doltDocsColumns) +} + // HasDoltPrefix returns a boolean whether or not the provided string is prefixed with the DoltNamespace. Users should // not be able to create tables in this reserved namespace. func HasDoltPrefix(s string) bool { @@ -162,16 +183,10 @@ const ( ReadmeDoc = "README.md" ) -var doltDocsColumns = schema.NewColCollection( - schema.NewColumn(DocPkColumnName, schema.DocNameTag, types.StringKind, true, schema.NotNullConstraint{}), - schema.NewColumn(DocTextColumnName, schema.DocTextTag, types.StringKind, false), -) -var DocsSchema = schema.MustSchemaFromCols(doltDocsColumns) - var DocsMaybeCreateTableStmt = ` CREATE TABLE IF NOT EXISTS dolt_docs ( doc_name varchar(16383) NOT NULL, - doc_text varchar(16383), + doc_text longtext, PRIMARY KEY (doc_name) );` diff --git a/go/libraries/doltcore/sqle/database.go b/go/libraries/doltcore/sqle/database.go index 313e28ca06..4963305021 100644 --- a/go/libraries/doltcore/sqle/database.go +++ b/go/libraries/doltcore/sqle/database.go @@ -851,7 +851,7 @@ func (db Database) CreateTable(ctx *sql.Context, tableName string, sch sql.Prima } if strings.ToLower(tableName) == doltdb.DocTableName { // validate correct schema - if !dtables.DoltDocsSqlSchema.Equals(sch.Schema) { + if !dtables.DoltDocsSqlSchema.Equals(sch.Schema) && !dtables.OldDoltDocsSqlSchema.Equals(sch.Schema) { return fmt.Errorf("incorrect schema for dolt_docs table") } } else if doltdb.HasDoltPrefix(tableName) { @@ -872,7 +872,7 @@ func (db Database) CreateIndexedTable(ctx *sql.Context, tableName string, sch sq } if strings.ToLower(tableName) == doltdb.DocTableName { // validate correct schema - if !dtables.DoltDocsSqlSchema.Equals(sch.Schema) { + if !dtables.DoltDocsSqlSchema.Equals(sch.Schema) && !dtables.OldDoltDocsSqlSchema.Equals(sch.Schema) { return fmt.Errorf("incorrect schema for dolt_docs table") } } else if doltdb.HasDoltPrefix(tableName) { diff --git a/go/libraries/doltcore/sqle/dtables/docs_table.go b/go/libraries/doltcore/sqle/dtables/docs_table.go index 5a237b5d33..0d23509b70 100644 --- a/go/libraries/doltcore/sqle/dtables/docs_table.go +++ b/go/libraries/doltcore/sqle/dtables/docs_table.go @@ -22,7 +22,9 @@ import ( ) var DoltDocsSqlSchema sql.PrimaryKeySchema +var OldDoltDocsSqlSchema sql.PrimaryKeySchema func init() { DoltDocsSqlSchema, _ = sqlutil.FromDoltSchema(doltdb.DocTableName, doltdb.DocsSchema) + OldDoltDocsSqlSchema, _ = sqlutil.FromDoltSchema(doltdb.DocTableName, doltdb.OldDocsSchema) } diff --git a/go/libraries/doltcore/sqle/sqlselect_test.go b/go/libraries/doltcore/sqle/sqlselect_test.go index 71ed5fc9d7..0bee758c27 100644 --- a/go/libraries/doltcore/sqle/sqlselect_test.go +++ b/go/libraries/doltcore/sqle/sqlselect_test.go @@ -1292,9 +1292,8 @@ var systemTableSelectTests = []SelectTest{ Name: "select from dolt_docs", AdditionalSetup: CreateTableFn("dolt_docs", doltdb.DocsSchema, "INSERT INTO dolt_docs VALUES ('LICENSE.md','A license')"), - Query: "select * from dolt_docs", - ExpectedRows: ToSqlRows(CompressSchema(doltdb.DocsSchema), - NewRow(types.String("LICENSE.md"), types.String("A license"))), + Query: "select * from dolt_docs", + ExpectedRows: []sql.Row{{"LICENSE.md", "A license"}}, ExpectedSchema: CompressSchema(doltdb.DocsSchema), }, { diff --git a/integration-tests/bats/docs.bats b/integration-tests/bats/docs.bats index 17d6bd0dca..6f3b836fc6 100644 --- a/integration-tests/bats/docs.bats +++ b/integration-tests/bats/docs.bats @@ -111,7 +111,7 @@ teardown() { dolt sql <