Skip to content

Commit 4a03413

Browse files
Nicholas Santikyleconroy
authored andcommitted
Fix schema in query context
1 parent 1c90340 commit 4a03413

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{ dbarg }} {{.Arg.Pair}}
138138

139139
{{define "queryCodeStdExec"}}
140140
{{- if .Arg.HasSqlcSlices }}
141-
query := {{.ConstantName}}
141+
query := strings.ReplaceAll({{.ConstantName}}, "%s", schema)
142142
var queryParams []interface{}
143143
{{- if .Arg.Struct }}
144144
{{- $arg := .Arg }}
@@ -186,6 +186,10 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{ dbarg }} {{.Arg.Pair}}
186186
{{- else if emitPreparedQueries }}
187187
{{- queryRetval . }} {{ queryMethod . }}(ctx, q.{{.FieldName}}, {{.ConstantName}}, {{.Arg.Params}})
188188
{{- else}}
189+
{{- if emitSchemaName }}
190+
{{- queryRetval . }} {{ queryMethod . }}(ctx, strings.ReplaceAll({{.ConstantName}}, "%s", schema), {{.Arg.Params}})
191+
{{- else }}
189192
{{- queryRetval . }} {{ queryMethod . }}(ctx, {{.ConstantName}}, {{.Arg.Params}})
193+
{{- end -}}
190194
{{- end -}}
191195
{{end}}

internal/codegen/golang/templates/template.tmpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ import (
180180
{{end}}
181181
{{end}}
182182

183-
{{- if emitSchemaName }}
184-
"strings"
185-
{{- end }}
186183
)
187184
{{end}}
188185

0 commit comments

Comments
 (0)