MCPcopy Index your code
hub / github.com/riverqueue/river / WithReplacements

Function WithReplacements

rivershared/sqlctemplate/sqlc_template.go:258–273  ·  view source on GitHub ↗

WithReplacements adds sqlctemplate templates to the given context (they go in context because it's the only way to get them down into the innards of sqlc). namedArgs can also be passed in to replace arguments found in If sqlctemplate params are already present in context, the two sets are merged, w

(ctx context.Context, replacements map[string]Replacement, namedArgs map[string]any)

Source from the content-addressed store, hash-verified

256// If sqlctemplate params are already present in context, the two sets are
257// merged, with the new params taking precedent.
258func WithReplacements(ctx context.Context, replacements map[string]Replacement, namedArgs map[string]any) context.Context {
259 if container, ok := ctx.Value(contextKey{}).(*contextContainer); ok {
260 maps.Copy(container.NamedArgs, namedArgs)
261 maps.Copy(container.Replacements, replacements)
262 return ctx
263 }
264
265 if namedArgs == nil {
266 namedArgs = make(map[string]any)
267 }
268
269 return context.WithValue(ctx, contextKey{}, &contextContainer{
270 NamedArgs: namedArgs,
271 Replacements: replacements,
272 })
273}
274
275// Comparable struct that's used as a key for template caching.
276type replacerCacheKey struct {

Callers 15

ColumnExistsMethod · 0.92
JobDeleteManyMethod · 0.92
JobListMethod · 0.92
schemaTemplateParamFunction · 0.92
ColumnExistsMethod · 0.92
JobDeleteManyMethod · 0.92
JobListMethod · 0.92
schemaTemplateParamFunction · 0.92
JobDeleteManyMethod · 0.92
JobGetAvailableMethod · 0.92
JobListMethod · 0.92
schemaTemplateParamFunction · 0.92

Calls 1

ValueMethod · 0.45

Tested by 3

TestMigratorFunction · 0.74
TestReplacerFunction · 0.68
BenchmarkReplacerFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…