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

Method UpdateField

core/procedures/root_object.go:256–285  ·  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

254
255// UpdateField implements the interface objinterface.Collection.
256func (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}

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.92
ParameterModesFromStringFunction · 0.85
ReplaceDefinitionMethod · 0.45

Tested by

no test coverage detected