RenameRootObject implements the interface objinterface.Collection.
(ctx context.Context, oldName id.Id, newName id.Id)
| 113 | |
| 114 | // RenameRootObject implements the interface objinterface.Collection. |
| 115 | func (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. |
| 133 | func (pgc *Collection) ResolveName(ctx context.Context, name doltdb.TableName) (doltdb.TableName, id.Id, error) { |