UpdateField implements the interface objinterface.Collection.
(ctx context.Context, rootObject objinterface.RootObject, fieldName string, newValue any)
| 254 | |
| 255 | // UpdateField implements the interface objinterface.Collection. |
| 256 | func (pgp *Collection) UpdateField(ctx context.Context, rootObject objinterface.RootObject, fieldName string, newValue any) (objinterface.RootObject, error) { |
| 257 | procedure := rootObject.(Procedure) |
| 258 | switch fieldName { |
| 259 | case FIELD_NAME_PARAMETER_NAMES: |
| 260 | procedure.ParameterNames = strings.Split(newValue.(string), ",") |
| 261 | case FIELD_NAME_PARAMETER_MODES: |
| 262 | newModes, err := ParameterModesFromString(newValue.(string)) |
| 263 | if err != nil { |
| 264 | return nil, err |
| 265 | } |
| 266 | procedure.ParameterModes = newModes |
| 267 | case FIELD_NAME_DEFINITION: |
| 268 | newDefinition := procedure.ReplaceDefinition(newValue.(string)) |
| 269 | parsedBody, err := plpgsql.Parse(newDefinition) |
| 270 | if err != nil { |
| 271 | return nil, err |
| 272 | } |
| 273 | procedure.Definition = newDefinition |
| 274 | procedure.Operations = parsedBody |
| 275 | case FIELD_NAME_EXTENSION_NAME: |
| 276 | procedure.ExtensionName = newValue.(string) |
| 277 | case FIELD_NAME_EXTENSION_SYMBOL: |
| 278 | procedure.ExtensionSymbol = newValue.(string) |
| 279 | case FIELD_NAME_SQL_DEFINITION: |
| 280 | procedure.SQLDefinition = newValue.(string) |
| 281 | default: |
| 282 | return nil, errors.Newf("unknown field name: `%s`", fieldName) |
| 283 | } |
| 284 | return procedure, nil |
| 285 | } |
nothing calls this directly
no test coverage detected