From d68dc916d0bbd8043ff6733b28a52c2b90a7c015 Mon Sep 17 00:00:00 2001 From: Adam Tobiasz Date: Fri, 13 Dec 2024 12:31:19 +0100 Subject: [PATCH] fix missing schema in table alias in pkEQ and pkIN clauses --- gen/templates/models/table/05_one_methods.go.tpl | 2 +- gen/templates/models/table/07_slice_methods.go.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gen/templates/models/table/05_one_methods.go.tpl b/gen/templates/models/table/05_one_methods.go.tpl index f6d20c8..de6e747 100644 --- a/gen/templates/models/table/05_one_methods.go.tpl +++ b/gen/templates/models/table/05_one_methods.go.tpl @@ -43,7 +43,7 @@ func (o *{{$tAlias.UpSingular}}) PrimaryKeyVals() bob.Expression { {{$pkCols := $table.Constraints.Primary.Columns}} {{$multiPK := gt (len $pkCols) 1}} func (o *{{$tAlias.UpSingular}}) pkEQ() dialect.Expression { - return {{if $multiPK}}{{$.Dialect}}.Group({{end}}{{- range $i, $col := $pkCols -}}{{if gt $i 0}}, {{end}}{{$.Dialect}}.Quote("{{$table.Name}}", "{{$col}}"){{end}}{{if $multiPK}}){{end -}} + return {{if $multiPK}}{{$.Dialect}}.Group({{end}}{{- range $i, $col := $pkCols -}}{{if gt $i 0}}, {{end}}{{$.Dialect}}.Quote("{{$table.Key}}", "{{$col}}"){{end}}{{if $multiPK}}){{end -}} .EQ(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error){ return o.PrimaryKeyVals().WriteSQL(ctx, w, d, start) })) diff --git a/gen/templates/models/table/07_slice_methods.go.tpl b/gen/templates/models/table/07_slice_methods.go.tpl index b9d9ab7..46c3640 100644 --- a/gen/templates/models/table/07_slice_methods.go.tpl +++ b/gen/templates/models/table/07_slice_methods.go.tpl @@ -35,7 +35,7 @@ func (o {{$tAlias.UpSingular}}Slice) pkIN() dialect.Expression { return {{$.Dialect}}.Raw("NULL") } - return {{if $multiPK}}{{$.Dialect}}.Group({{end}}{{- range $i, $col := $pkCols -}}{{if gt $i 0}}, {{end}}{{$.Dialect}}.Quote("{{$table.Name}}", "{{$col}}"){{end}}{{if $multiPK}}){{end -}} + return {{if $multiPK}}{{$.Dialect}}.Group({{end}}{{- range $i, $col := $pkCols -}}{{if gt $i 0}}, {{end}}{{$.Dialect}}.Quote("{{$table.Key}}", "{{$col}}"){{end}}{{if $multiPK}}){{end -}} .In(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error){ pkPairs := make([]bob.Expression, len(o)) for i, row := range o {