UpdateField implements the interface objinterface.Collection.
(ctx context.Context, rootObject objinterface.RootObject, fieldName string, newValue any)
| 292 | |
| 293 | // UpdateField implements the interface objinterface.Collection. |
| 294 | func (pgf *Collection) UpdateField(ctx context.Context, rootObject objinterface.RootObject, fieldName string, newValue any) (objinterface.RootObject, error) { |
| 295 | function := rootObject.(Function) |
| 296 | switch fieldName { |
| 297 | case FIELD_NAME_PARAMETER_NAMES: |
| 298 | function.ParameterNames = strings.Split(newValue.(string), ",") |
| 299 | case FIELD_NAME_RETURN_TYPE: |
| 300 | function.ReturnType = id.NewType(function.ReturnType.SchemaName(), newValue.(string)) |
| 301 | case FIELD_NAME_NON_DETERMINISTIC: |
| 302 | function.IsNonDeterministic = newValue.(bool) |
| 303 | case FIELD_NAME_STRICT: |
| 304 | function.Strict = newValue.(bool) |
| 305 | case FIELD_NAME_DEFINITION: |
| 306 | function.Definition = function.ReplaceDefinition(newValue.(string)) |
| 307 | parsedBody, err := plpgsql.Parse(function.Definition) |
| 308 | if err != nil { |
| 309 | return nil, err |
| 310 | } |
| 311 | function.Operations = parsedBody |
| 312 | case FIELD_NAME_EXTENSION_NAME: |
| 313 | function.ExtensionName = newValue.(string) |
| 314 | case FIELD_NAME_EXTENSION_SYMBOL: |
| 315 | function.ExtensionSymbol = newValue.(string) |
| 316 | case FIELD_NAME_SQL_DEFINITION: |
| 317 | function.SQLDefinition = newValue.(string) |
| 318 | case FIELD_NAME_SET_OF: |
| 319 | function.SetOf = newValue.(bool) |
| 320 | default: |
| 321 | return nil, errors.Newf("unknown field name: `%s`", fieldName) |
| 322 | } |
| 323 | return function, nil |
| 324 | } |
nothing calls this directly
no test coverage detected