RenameRootObject implements the interface objinterface.Collection.
(ctx context.Context, oldName id.Id, newName id.Id)
| 256 | |
| 257 | // RenameRootObject implements the interface objinterface.Collection. |
| 258 | func (pgf *Collection) RenameRootObject(ctx context.Context, oldName id.Id, newName id.Id) error { |
| 259 | if !oldName.IsValid() || !newName.IsValid() || oldName.Section() != newName.Section() || oldName.Section() != id.Section_Function { |
| 260 | return errors.New("cannot rename function due to invalid name") |
| 261 | } |
| 262 | oldFuncName := id.Function(oldName) |
| 263 | newFuncName := id.Function(newName) |
| 264 | if oldFuncName.ParameterCount() != newFuncName.ParameterCount() { |
| 265 | return errors.Newf(`old function id had "%d" parameters, new function id has "%d" parameters`, |
| 266 | oldFuncName.ParameterCount(), newFuncName.ParameterCount()) |
| 267 | } |
| 268 | f, err := pgf.GetFunction(ctx, oldFuncName) |
| 269 | if err != nil { |
| 270 | return err |
| 271 | } |
| 272 | if err = pgf.DropFunction(ctx, oldFuncName); err != nil { |
| 273 | return err |
| 274 | } |
| 275 | f.ID = newFuncName |
| 276 | return pgf.AddFunction(ctx, f) |
| 277 | } |
| 278 | |
| 279 | // ResolveName implements the interface objinterface.Collection. |
| 280 | func (pgf *Collection) ResolveName(ctx context.Context, name doltdb.TableName) (doltdb.TableName, id.Id, error) { |
nothing calls this directly
no test coverage detected