MCPcopy Create free account
hub / github.com/cloudwan/gohan / UpdateContext

Method UpdateContext

db/sql/sql.go:684–701  ·  view source on GitHub ↗

Update update resource in the db

(ctx context.Context, resource *schema.Resource)

Source from the content-addressed store, hash-verified

682
683//Update update resource in the db
684func (tx *Transaction) UpdateContext(ctx context.Context, resource *schema.Resource) error {
685 defer tx.measureTime(time.Now(), resource.Schema().ID, "update")
686
687 q, err := tx.updateQuery(resource)
688 if err != nil {
689 return err
690 }
691 sql, args, err := q.ToSql()
692 if err != nil {
693 return err
694 }
695 if resource.Schema().StateVersioning() {
696 sql += ", `" + configVersionColumnName + "` = `" + configVersionColumnName + "` + 1"
697 }
698 sql += " WHERE id = ?"
699 args = append(args, resource.ID())
700 return tx.exec(ctx, sql, args...)
701}
702
703func (tx *Transaction) StateUpdate(resource *schema.Resource, state *transaction.ResourceState) error {
704 return tx.StateUpdateContext(context.Background(), resource, state)

Callers 1

UpdateMethod · 0.95

Calls 6

measureTimeMethod · 0.95
updateQueryMethod · 0.95
execMethod · 0.95
StateVersioningMethod · 0.80
SchemaMethod · 0.65
IDMethod · 0.65

Tested by

no test coverage detected