MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / prepareUpdateMutation

Function prepareUpdateMutation

lib/gcpspanner/client.go:1613–1636  ·  view source on GitHub ↗

prepareUpdateMutation is a helper that extracts the ID and merges the entity using the mapper. nolint:ireturn // ID is a type parameter, not a generic interface.

(row *spanner.Row, input ExternalStruct)

Source from the content-addressed store, hash-verified

1611func prepareInsertMutation[
1612 M writeableEntityMapperWithIDRetrieval[ExternalStruct, SpannerStruct, Key, ID],
1613 ExternalStruct any,
1614 SpannerStruct any,
1615 Key comparable,
1616 ID any](input ExternalStruct) (*spanner.Mutation, ID, error) {
1617 var mapper M
1618 spannerEntity, newID, err := mapper.NewEntityWithID(input)
1619 if err != nil {
1620 return nil, *new(ID), err
1621 }
1622
1623 m, err := spanner.InsertStruct(mapper.Table(), spannerEntity)
1624 if err != nil {
1625 return nil, *new(ID), errors.Join(ErrInternalMutationFailure, err)
1626 }
1627
1628 return m, newID, nil
1629}
1630
1631// prepareUpdateMutation is a helper that extracts the ID and merges the entity using the mapper.
1632// nolint:ireturn // ID is a type parameter, not a generic interface.
1633func prepareUpdateMutation[
1634 M writeableEntityMapperWithIDRetrieval[ExternalStruct, SpannerStruct, Key, ID],
1635 ExternalStruct any,
1636 SpannerStruct any,
1637 Key comparable,
1638 ID any](row *spanner.Row, input ExternalStruct) (*spanner.Mutation, ID, error) {
1639 var mapper M

Callers 1

upsertAndGetIDMethod · 0.85

Calls 3

GetIDFromInternalMethod · 0.65
MergeMethod · 0.65
TableMethod · 0.65

Tested by

no test coverage detected