Fix non-int comparisons

This commit is contained in:
Patrick O'brien 2016-09-17 13:13:44 +10:00
parent ab67fddac3
commit 6c13b63500
3 changed files with 32 additions and 26 deletions

View file

@ -101,19 +101,22 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
return ErrSyncFail return ErrSyncFail
} }
if lastID != 0 {
{{- $colName := index .Table.PKey.Columns 0 -}} {{- $colName := index .Table.PKey.Columns 0 -}}
{{- $col := .Table.GetColumn $colName -}} {{- $col := .Table.GetColumn $colName -}}
{{- $colTitled := $colName | singular | titleCase}} {{- $colTitled := $colName | singular | titleCase}}
{{if eq 1 (len .Table.PKey.Columns)}}
{{$cnames := .Table.Columns | filterColumnsByDefault true | columnNames}}
{{if setInclude $colName $cnames}}
o.{{$colTitled}} = {{$col.Type}}(lastID) o.{{$colTitled}} = {{$col.Type}}(lastID)
identifierCols = []interface{}{lastID} identifierCols = []interface{}{lastID}
} else { {{end}}
{{else}}
identifierCols = []interface{}{ identifierCols = []interface{}{
{{range .Table.PKey.Columns -}} {{range .Table.PKey.Columns -}}
o.{{. | singular | titleCase}}, o.{{. | singular | titleCase}},
{{end -}} {{end -}}
} }
} {{end}}
if lastID == 0 || len(cache.retMapping) != 1 || cache.retMapping[0] == {{$varNameSingular}}Mapping["{{$colTitled}}"] { if lastID == 0 || len(cache.retMapping) != 1 || cache.retMapping[0] == {{$varNameSingular}}Mapping["{{$colTitled}}"] {
if boil.DebugMode { if boil.DebugMode {

View file

@ -142,19 +142,22 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if ne .DriverName
return ErrSyncFail return ErrSyncFail
} }
if lastID != 0 {
{{- $colName := index .Table.PKey.Columns 0 -}} {{- $colName := index .Table.PKey.Columns 0 -}}
{{- $col := .Table.GetColumn $colName -}} {{- $col := .Table.GetColumn $colName -}}
{{- $colTitled := $colName | singular | titleCase}} {{- $colTitled := $colName | singular | titleCase}}
{{if eq 1 (len .Table.PKey.Columns)}}
{{$cnames := .Table.Columns | filterColumnsByDefault true | columnNames}}
{{if setInclude $colName $cnames}}
o.{{$colTitled}} = {{$col.Type}}(lastID) o.{{$colTitled}} = {{$col.Type}}(lastID)
identifierCols = []interface{}{lastID} identifierCols = []interface{}{lastID}
} else { {{end}}
{{else}}
identifierCols = []interface{}{ identifierCols = []interface{}{
{{range .Table.PKey.Columns -}} {{range .Table.PKey.Columns -}}
o.{{. | singular | titleCase}}, o.{{. | singular | titleCase}},
{{end -}} {{end -}}
} }
} {{end}}
if lastID == 0 || len(cache.retMapping) != 1 || cache.retMapping[0] == {{$varNameSingular}}Mapping["{{$colTitled}}"] { if lastID == 0 || len(cache.retMapping) != 1 || cache.retMapping[0] == {{$varNameSingular}}Mapping["{{$colTitled}}"] {
if boil.DebugMode { if boil.DebugMode {

View file

@ -2,7 +2,7 @@
{{- $dot := .Dot -}} {{- $dot := .Dot -}}
{{- with .Rel -}} {{- with .Rel -}}
{{- $varNameSingular := .ForeignKey.Table | singular | camelCase -}} {{- $varNameSingular := .ForeignKey.Table | singular | camelCase -}}
{{- $foreignVarNameSingular := .ForeignKey.ForeignTable | singular | camelCase}} {{- $foreignVarNameSingular := .ForeignKey.ForeignTable | singular | camelCase -}}
{{- $foreignTable := getTable $dot.Tables .ForeignKey.ForeignTable -}} {{- $foreignTable := getTable $dot.Tables .ForeignKey.ForeignTable -}}
{{- $foreignTableFKeyCol := $foreignTable.GetColumn .ForeignKey.ForeignColumn -}} {{- $foreignTableFKeyCol := $foreignTable.GetColumn .ForeignKey.ForeignColumn -}}
{{- $usesBytes := eq "[]byte" $foreignTableFKeyCol.Type -}} {{- $usesBytes := eq "[]byte" $foreignTableFKeyCol.Type -}}