mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-27 18:59:23 -06:00
Don't panic when unmarshelling a schema with missing chunks
This commit is contained in:
@@ -466,6 +466,9 @@ func UnmarshalSchemaAtAddr(ctx context.Context, vr types.ValueReader, addr hash.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if schemaVal == nil {
|
||||
return nil, fmt.Errorf("database malformed: no schema found at address %s", addr.String())
|
||||
}
|
||||
|
||||
sch, err := UnmarshalSchema(ctx, vr.Format(), schemaVal)
|
||||
if err != nil {
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/dolthub/dolt/go/store/hash"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
gmstypes "github.com/dolthub/go-mysql-server/sql/types"
|
||||
"github.com/dolthub/vitess/go/sqltypes"
|
||||
@@ -51,6 +52,13 @@ func createTestSchema() schema.Schema {
|
||||
return sch
|
||||
}
|
||||
|
||||
func TestSchemaUnmarshal(t *testing.T) {
|
||||
_, vrw, _, err := dbfactory.MemFactory{}.CreateDB(context.Background(), types.Format_Default, nil, nil)
|
||||
val, err := UnmarshalSchemaAtAddr(context.Background(), vrw, hash.Parse("badaddrvvvvvvvvvvvvvvvvvvvvvvvvv"))
|
||||
require.Error(t, err)
|
||||
require.Nil(t, val)
|
||||
}
|
||||
|
||||
func TestNomsMarshalling(t *testing.T) {
|
||||
tSchema := createTestSchema()
|
||||
_, vrw, _, err := dbfactory.MemFactory{}.CreateDB(context.Background(), types.Format_Default, nil, nil)
|
||||
|
||||
Reference in New Issue
Block a user