MCPcopy Index your code
hub / github.com/bytebase/bytebase / DropView

Method DropView

backend/store/model/database.go:635–661  ·  view source on GitHub ↗

DropView drops a view from the schema. Returns an error if the view does not exist.

(viewName string)

Source from the content-addressed store, hash-verified

633// DropView drops a view from the schema.
634// Returns an error if the view does not exist.
635func (s *SchemaMetadata) DropView(viewName string) error {
636 // Check if view exists
637 if s.GetView(viewName) == nil {
638 return errors.Errorf("view %q does not exist in schema %q", viewName, s.proto.Name)
639 }
640
641 // Remove from internal map
642 viewID := normalizeNameByCaseSensitivity(viewName, s.isObjectCaseSensitive)
643 delete(s.internalViews, viewID)
644
645 // Remove from proto's view list
646 newViews := make([]*storepb.ViewMetadata, 0, len(s.proto.Views)-1)
647 for _, view := range s.proto.Views {
648 if s.isObjectCaseSensitive {
649 if view.Name != viewName {
650 newViews = append(newViews, view)
651 }
652 } else {
653 if !strings.EqualFold(view.Name, viewName) {
654 newViews = append(newViews, view)
655 }
656 }
657 }
658 s.proto.Views = newViews
659
660 return nil
661}
662
663// RenameView renames a view in the schema.
664// Returns an error if the old view doesn't exist or new view already exists.

Callers

nothing calls this directly

Calls 3

GetViewMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected