Skip to content

Commit

Permalink
Merge pull request #1328 from motemen/fix-insert-pkey-alias
Browse files Browse the repository at this point in the history
fix: use aliased field name for LastInsertID
  • Loading branch information
stephenafamo authored Nov 26, 2023
2 parents 73f2bf0 + edf678b commit 1ed4b2b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions templates/main/15_insert.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ func (o *{{$alias.UpSingular}}) Insert({{if .NoContext}}exec boil.Executor{{else

{{$colName := index .Table.PKey.Columns 0 -}}
{{- $col := .Table.GetColumn $colName -}}
{{- $colTitled := $colName | titleCase}}
o.{{$colTitled}} = {{$col.Type}}(lastID)
o.{{$alias.Column $colName}} = {{$col.Type}}(lastID)
if lastID != 0 && len(cache.retMapping) == 1 && cache.retMapping[0] == {{$alias.DownSingular}}Mapping["{{$colName}}"] {
goto CacheNoHooks
}
Expand Down

0 comments on commit 1ed4b2b

Please sign in to comment.