diff --git a/CHANGELOG.md b/CHANGELOG.md index 212cc0c..3b3083b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed data races in unit tests. (thanks @mbezhanov) - Fixed invalid SQL statements generated by `sm.OrderBy().Collate()`. (thanks @mbezhanov) - Fixed a bug preventing specific columns from being excluded when generating models from SQLite. (thanks @mbezhanov) +- Fixed an issue where invalid code is generated if a configured relationship has `from_where` or `to_where`. ## [v0.28.1] - 2024-06-28 diff --git a/gen/templates/models/09_rel_query.go.tpl b/gen/templates/models/09_rel_query.go.tpl index 82ffcc2..c409073 100644 --- a/gen/templates/models/09_rel_query.go.tpl +++ b/gen/templates/models/09_rel_query.go.tpl @@ -137,11 +137,11 @@ func (os {{$tAlias.UpSingular}}Slice) {{relQueryMethodName $tAlias $relAlias}}(c {{- end}} {{- range $where := $side.FromWhere}} {{- $fromCol := index $from.Columns $where.Column}} - sm.Where({{$from.UpSingular}}Columns.{{$fromCol}}.EQ({{$.Dialect}}.Arg({{quote $where.SQLValue}}))), + {{$from.UpSingular}}Columns.{{$fromCol}}.EQ({{$.Dialect}}.Arg({{quote $where.SQLValue}})), {{- end}} {{- range $where := $side.ToWhere}} {{- $toCol := index $to.Columns $where.Column}} - sm.Where({{$to.UpSingular}}Columns.{{$toCol}}.EQ({{$.Dialect}}.Arg({{quote $where.SQLValue}}))), + {{$to.UpSingular}}Columns.{{$toCol}}.EQ({{$.Dialect}}.Arg({{quote $where.SQLValue}})), {{- end}} ), {{- else -}}