MCPcopy Create free account
hub / github.com/dolthub/doltgresql / UpdateField

Method UpdateField

core/functions/root_object.go:294–324  ·  view source on GitHub ↗

UpdateField implements the interface objinterface.Collection.

(ctx context.Context, rootObject objinterface.RootObject, fieldName string, newValue any)

Source from the content-addressed store, hash-verified

292
293// UpdateField implements the interface objinterface.Collection.
294func (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}

Callers

nothing calls this directly

Calls 4

NewTypeFunction · 0.92
ParseFunction · 0.92
SchemaNameMethod · 0.45
ReplaceDefinitionMethod · 0.45

Tested by

no test coverage detected