RenameRootObject implements the interface objinterface.Collection.
(ctx context.Context, oldName id.Id, newName id.Id)
| 218 | |
| 219 | // RenameRootObject implements the interface objinterface.Collection. |
| 220 | func (pgp *Collection) RenameRootObject(ctx context.Context, oldName id.Id, newName id.Id) error { |
| 221 | if !oldName.IsValid() || !newName.IsValid() || oldName.Section() != newName.Section() || oldName.Section() != id.Section_Procedure { |
| 222 | return errors.New("cannot rename procedure due to invalid name") |
| 223 | } |
| 224 | oldProcName := id.Procedure(oldName) |
| 225 | newProcName := id.Procedure(newName) |
| 226 | if oldProcName.ParameterCount() != newProcName.ParameterCount() { |
| 227 | return errors.Newf(`old procedure id had "%d" parameters, new procedure id has "%d" parameters`, |
| 228 | oldProcName.ParameterCount(), newProcName.ParameterCount()) |
| 229 | } |
| 230 | proc, err := pgp.GetProcedure(ctx, oldProcName) |
| 231 | if err != nil { |
| 232 | return err |
| 233 | } |
| 234 | if err = pgp.DropProcedure(ctx, oldProcName); err != nil { |
| 235 | return err |
| 236 | } |
| 237 | proc.ID = newProcName |
| 238 | return pgp.AddProcedure(ctx, proc) |
| 239 | } |
| 240 | |
| 241 | // ResolveName implements the interface objinterface.Collection. |
| 242 | func (pgp *Collection) ResolveName(ctx context.Context, name doltdb.TableName) (doltdb.TableName, id.Id, error) { |
nothing calls this directly
no test coverage detected