MCPcopy Create free account
hub / github.com/dolthub/doltgresql / RenameRootObject

Method RenameRootObject

core/casts/root_object.go:115–130  ·  view source on GitHub ↗

RenameRootObject implements the interface objinterface.Collection.

(ctx context.Context, oldName id.Id, newName id.Id)

Source from the content-addressed store, hash-verified

113
114// RenameRootObject implements the interface objinterface.Collection.
115func (pgc *Collection) RenameRootObject(ctx context.Context, oldName id.Id, newName id.Id) error {
116 if !oldName.IsValid() || !newName.IsValid() || oldName.Section() != newName.Section() || oldName.Section() != id.Section_Cast {
117 return errors.New("cannot rename cast due to invalid id")
118 }
119 oldCastName := id.Cast(oldName)
120 newCastName := id.Cast(newName)
121 c, err := pgc.getCast(ctx, oldCastName, nil, nil, CastType_Explicit)
122 if err != nil {
123 return err
124 }
125 if err = pgc.DropCast(ctx, newCastName); err != nil {
126 return err
127 }
128 c.ID = newCastName
129 return pgc.AddCast(ctx, c)
130}
131
132// ResolveName implements the interface objinterface.Collection.
133func (pgc *Collection) ResolveName(ctx context.Context, name doltdb.TableName) (doltdb.TableName, id.Id, error) {

Callers

nothing calls this directly

Calls 6

getCastMethod · 0.95
DropCastMethod · 0.95
AddCastMethod · 0.95
CastTypeAlias · 0.92
SectionMethod · 0.80
IsValidMethod · 0.45

Tested by

no test coverage detected