diff --git a/internal/codegen/golang/templates/stdlib/queryCode.tmpl b/internal/codegen/golang/templates/stdlib/queryCode.tmpl index 9a4ea576d5..8c622d0f27 100644 --- a/internal/codegen/golang/templates/stdlib/queryCode.tmpl +++ b/internal/codegen/golang/templates/stdlib/queryCode.tmpl @@ -138,7 +138,7 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{ dbarg }} {{.Arg.Pair}} {{define "queryCodeStdExec"}} {{- if .Arg.HasSqlcSlices }} - query := {{.ConstantName}} + query := strings.ReplaceAll({{.ConstantName}}, "%s", schema) var queryParams []interface{} {{- if .Arg.Struct }} {{- $arg := .Arg }} @@ -186,6 +186,10 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{ dbarg }} {{.Arg.Pair}} {{- else if emitPreparedQueries }} {{- queryRetval . }} {{ queryMethod . }}(ctx, q.{{.FieldName}}, {{.ConstantName}}, {{.Arg.Params}}) {{- else}} + {{- if emitSchemaName }} + {{- queryRetval . }} {{ queryMethod . }}(ctx, strings.ReplaceAll({{.ConstantName}}, "%s", schema), {{.Arg.Params}}) + {{- else }} {{- queryRetval . }} {{ queryMethod . }}(ctx, {{.ConstantName}}, {{.Arg.Params}}) + {{- end -}} {{- end -}} {{end}} diff --git a/internal/codegen/golang/templates/template.tmpl b/internal/codegen/golang/templates/template.tmpl index 665e1f9cda..d4dfcdcbef 100644 --- a/internal/codegen/golang/templates/template.tmpl +++ b/internal/codegen/golang/templates/template.tmpl @@ -180,9 +180,6 @@ import ( {{end}} {{end}} - {{- if emitSchemaName }} - "strings" - {{- end }} ) {{end}}