Skip to content

Commit 1ed4b2b

Browse files
authored
Merge pull request #1328 from motemen/fix-insert-pkey-alias
fix: use aliased field name for LastInsertID
2 parents 73f2bf0 + edf678b commit 1ed4b2b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

templates/main/15_insert.go.tpl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ func (o *{{$alias.UpSingular}}) Insert({{if .NoContext}}exec boil.Executor{{else
152152

153153
{{$colName := index .Table.PKey.Columns 0 -}}
154154
{{- $col := .Table.GetColumn $colName -}}
155-
{{- $colTitled := $colName | titleCase}}
156-
o.{{$colTitled}} = {{$col.Type}}(lastID)
155+
o.{{$alias.Column $colName}} = {{$col.Type}}(lastID)
157156
if lastID != 0 && len(cache.retMapping) == 1 && cache.retMapping[0] == {{$alias.DownSingular}}Mapping["{{$colName}}"] {
158157
goto CacheNoHooks
159158
}

0 commit comments

Comments
 (0)