Fix MySQL return query optimization.
- Before, this could erroneously detect that it could do without the return query because it thought all we wanted was the id. Now with this fix it should properly discard the query when all we want is id.
This commit is contained in:
parent
bac82b6f0e
commit
b0b0ff87c6
2 changed files with 6 additions and 4 deletions
|
@ -104,7 +104,8 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
|
||||||
if lastID != 0 {
|
if lastID != 0 {
|
||||||
{{- $colName := index .Table.PKey.Columns 0 -}}
|
{{- $colName := index .Table.PKey.Columns 0 -}}
|
||||||
{{- $col := .Table.GetColumn $colName -}}
|
{{- $col := .Table.GetColumn $colName -}}
|
||||||
o.{{$colName | singular | titleCase}} = {{$col.Type}}(lastID)
|
{{- $colTitled := $colName | singular | titleCase}}
|
||||||
|
o.{{$colTitled}} = {{$col.Type}}(lastID)
|
||||||
identifierCols = []interface{}{lastID}
|
identifierCols = []interface{}{lastID}
|
||||||
} else {
|
} else {
|
||||||
identifierCols = []interface{}{
|
identifierCols = []interface{}{
|
||||||
|
@ -114,7 +115,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if lastID != 0 && len(cache.retMapping) == 1 {
|
if lastID == 0 || len(cache.retMapping) != 1 || cache.retMapping[0] == {{$varNameSingular}}Mapping["{{$colTitled}}"] {
|
||||||
if boil.DebugMode {
|
if boil.DebugMode {
|
||||||
fmt.Fprintln(boil.DebugWriter, cache.retQuery)
|
fmt.Fprintln(boil.DebugWriter, cache.retQuery)
|
||||||
fmt.Fprintln(boil.DebugWriter, identifierCols...)
|
fmt.Fprintln(boil.DebugWriter, identifierCols...)
|
||||||
|
|
|
@ -145,7 +145,8 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if ne .DriverName
|
||||||
if lastID != 0 {
|
if lastID != 0 {
|
||||||
{{- $colName := index .Table.PKey.Columns 0 -}}
|
{{- $colName := index .Table.PKey.Columns 0 -}}
|
||||||
{{- $col := .Table.GetColumn $colName -}}
|
{{- $col := .Table.GetColumn $colName -}}
|
||||||
o.{{$colName | singular | titleCase}} = {{$col.Type}}(lastID)
|
{{- $colTitled := $colName | singular | titleCase}}
|
||||||
|
o.{{$colTitled}} = {{$col.Type}}(lastID)
|
||||||
identifierCols = []interface{}{lastID}
|
identifierCols = []interface{}{lastID}
|
||||||
} else {
|
} else {
|
||||||
identifierCols = []interface{}{
|
identifierCols = []interface{}{
|
||||||
|
@ -155,7 +156,7 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if ne .DriverName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if lastID != 0 && len(cache.retMapping) == 1 {
|
if lastID == 0 || len(cache.retMapping) != 1 || cache.retMapping[0] == {{$varNameSingular}}Mapping["{{$colTitled}}"] {
|
||||||
if boil.DebugMode {
|
if boil.DebugMode {
|
||||||
fmt.Fprintln(boil.DebugWriter, cache.retQuery)
|
fmt.Fprintln(boil.DebugWriter, cache.retQuery)
|
||||||
fmt.Fprintln(boil.DebugWriter, identifierCols...)
|
fmt.Fprintln(boil.DebugWriter, identifierCols...)
|
||||||
|
|
Loading…
Reference in a new issue