Skip to content

Commit

Permalink
Merge pull request #327 from adatob/bugfix/missing-primary-key-schema…
Browse files Browse the repository at this point in the history
…-alias

Fix missing schema in table alias in pkEQ and pkIN clauses
  • Loading branch information
stephenafamo authored Dec 16, 2024
2 parents 1da2c27 + d68dc91 commit 962c620
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gen/templates/models/table/05_one_methods.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}))
Expand Down
2 changes: 1 addition & 1 deletion gen/templates/models/table/07_slice_methods.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 962c620

Please sign in to comment.