Added a failsafe validation for schemas about to be written to disk.

This commit is contained in:
Zach Musgrave
2021-01-26 16:51:24 -08:00
parent 4f7a0afbf7
commit 242edda60b
@@ -224,6 +224,13 @@ func (sd schemaData) decodeSchema() (schema.Schema, error) {
// MarshalSchemaAsNomsValue takes a Schema and converts it to a types.Value
func MarshalSchemaAsNomsValue(ctx context.Context, vrw types.ValueReadWriter, sch schema.Schema) (types.Value, error) {
// Anyone calling this is going to serialize this to disk, so it's our last line of defense against defective schemas.
// Business logic should catch errors before this point, but this is a failsafe.
err := schema.ValidateForInsert(sch.GetAllCols())
if err != nil {
return nil, err
}
sd, err := toSchemaData(sch)
if err != nil {