Skip to content

Commit

Permalink
[Go & Cpp] Validate schema when opening a space (#69)
Browse files Browse the repository at this point in the history
Signed-off-by: sunby <[email protected]>
  • Loading branch information
sunby committed Oct 8, 2023
1 parent c58990f commit 8692767
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cpp/src/storage/space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ Result<std::unique_ptr<Space>> Space::Open(const std::string& uri, Options optio
if (options.schema == nullptr) {
return Status::InvalidArgument("schema should not be nullptr");
}

RETURN_NOT_OK(options.schema->Validate());
manifest = std::make_shared<Manifest>(options.schema);
RETURN_NOT_OK(SafeSaveManifest(fs, path, manifest.get()));
} else {
Expand Down
3 changes: 3 additions & 0 deletions go/storage/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func Open(uri string, opt options.Options) (*Space, error) {
log.Error("schema is nil")
return nil, errors.ErrSchemaIsNil
}
if err = opt.Schema.Validate(); err != nil {
return nil, err
}
m = manifest.NewManifest(opt.Schema)
m.SetVersion(0) //TODO: check if this is necessary
if err = rw.Write(m); err != nil {
Expand Down

0 comments on commit 8692767

Please sign in to comment.