Skip to content

Commit ae8e08c

Browse files
authored
fix data race in wpgx invalidate generation (#13)
fix invalidate race in wpgx template
1 parent ebc9414 commit ae8e08c

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

internal/codegen/golang/templates/wpgx/queryCode.tmpl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ func _{{.MethodName}}(ctx context.Context, q {{.ConnType}}, {{.Arg.Pair}} {{.Inv
9999
if {{.ArgName}} != nil {
100100
{{ end -}}
101101
key := {{.CacheKey}}
102-
err = q.GetCache().Invalidate(ctx, key)
103-
if err != nil {
104-
log.Ctx(ctx).Error().Err(err).Msgf(
102+
invalidateErr := q.GetCache().Invalidate(ctx, key)
103+
if invalidateErr != nil {
104+
log.Ctx(ctx).Error().Err(invalidateErr).Msgf(
105105
"Failed to invalidate: %s", key)
106-
anyErr <- err
106+
anyErr <- invalidateErr
107107
}
108108
{{ if not .NoArg -}}
109109
}
@@ -203,11 +203,11 @@ func _{{.MethodName}}(ctx context.Context, q {{.ConnType}}, {{.Arg.Pair}} {{.Inv
203203
if {{.ArgName}} != nil {
204204
{{ end -}}
205205
key := {{.CacheKey}}
206-
err = q.GetCache().Invalidate(ctx, key)
207-
if err != nil {
208-
log.Ctx(ctx).Error().Err(err).Msgf(
206+
invalidateErr := q.GetCache().Invalidate(ctx, key)
207+
if invalidateErr != nil {
208+
log.Ctx(ctx).Error().Err(invalidateErr).Msgf(
209209
"Failed to invalidate: %s", key)
210-
anyErr <- err
210+
anyErr <- invalidateErr
211211
}
212212
{{ if not .NoArg -}}
213213
}
@@ -248,11 +248,11 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}} {{.Invalida
248248
if {{.ArgName}} != nil {
249249
{{ end -}}
250250
key := {{.CacheKey}}
251-
err = q.cache.Invalidate(ctx, key)
252-
if err != nil {
253-
log.Ctx(ctx).Error().Err(err).Msgf(
251+
invalidateErr := q.cache.Invalidate(ctx, key)
252+
if invalidateErr != nil {
253+
log.Ctx(ctx).Error().Err(invalidateErr).Msgf(
254254
"Failed to invalidate: %s", key)
255-
anyErr <- err
255+
anyErr <- invalidateErr
256256
}
257257
{{ if not .NoArg -}}
258258
}
@@ -293,11 +293,11 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}} {{.Invalida
293293
if {{.ArgName}} != nil {
294294
{{ end -}}
295295
key := {{.CacheKey}}
296-
err = q.cache.Invalidate(ctx, key)
297-
if err != nil {
298-
log.Ctx(ctx).Error().Err(err).Msgf(
296+
invalidateErr := q.cache.Invalidate(ctx, key)
297+
if invalidateErr != nil {
298+
log.Ctx(ctx).Error().Err(invalidateErr).Msgf(
299299
"Failed to invalidate: %s", key)
300-
anyErr <- err
300+
anyErr <- invalidateErr
301301
}
302302
{{ if not .NoArg -}}
303303
}
@@ -338,11 +338,11 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}} {{.Invalida
338338
if {{.ArgName}} != nil {
339339
{{ end -}}
340340
key := {{.CacheKey}}
341-
err = q.cache.Invalidate(ctx, key)
342-
if err != nil {
343-
log.Ctx(ctx).Error().Err(err).Msgf(
341+
invalidateErr := q.cache.Invalidate(ctx, key)
342+
if invalidateErr != nil {
343+
log.Ctx(ctx).Error().Err(invalidateErr).Msgf(
344344
"Failed to invalidate: %s", key)
345-
anyErr <- err
345+
anyErr <- invalidateErr
346346
}
347347
{{ if not .NoArg -}}
348348
}

0 commit comments

Comments
 (0)