Branching with if-else
This commit is contained in:
parent
8ef33a1127
commit
83b935168f
1 changed files with 2 additions and 6 deletions
|
@ -115,17 +115,13 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName
|
||||||
copy(conflict, {{$varNameSingular}}PrimaryKeyColumns)
|
copy(conflict, {{$varNameSingular}}PrimaryKeyColumns)
|
||||||
}
|
}
|
||||||
cache.query = queries.BuildUpsertQueryPostgres(dialect, "{{$schemaTable}}", updateOnConflict, ret, update, conflict, insert)
|
cache.query = queries.BuildUpsertQueryPostgres(dialect, "{{$schemaTable}}", updateOnConflict, ret, update, conflict, insert)
|
||||||
{{- end -}}
|
{{else if eq .DriverName "mysql"}}
|
||||||
|
|
||||||
{{if eq .DriverName "mysql"}}
|
|
||||||
cache.query = queries.BuildUpsertQueryMySQL(dialect, "{{.Table.Name}}", update, insert)
|
cache.query = queries.BuildUpsertQueryMySQL(dialect, "{{.Table.Name}}", update, insert)
|
||||||
cache.retQuery = fmt.Sprintf(
|
cache.retQuery = fmt.Sprintf(
|
||||||
"SELECT %s FROM {{.LQ}}{{.Table.Name}}{{.RQ}} WHERE {{whereClause .LQ .RQ 0 .Table.PKey.Columns}}",
|
"SELECT %s FROM {{.LQ}}{{.Table.Name}}{{.RQ}} WHERE {{whereClause .LQ .RQ 0 .Table.PKey.Columns}}",
|
||||||
strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, ret), ","),
|
strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, ret), ","),
|
||||||
)
|
)
|
||||||
{{- end -}}
|
{{else if eq .DriverName "mssql"}}
|
||||||
|
|
||||||
{{if eq .DriverName "mssql"}}
|
|
||||||
cache.query = queries.BuildUpsertQueryMSSQL(dialect, "{{.Table.Name}}", {{$varNameSingular}}PrimaryKeyColumns, update, insert, ret)
|
cache.query = queries.BuildUpsertQueryMSSQL(dialect, "{{.Table.Name}}", {{$varNameSingular}}PrimaryKeyColumns, update, insert, ret)
|
||||||
|
|
||||||
whitelist = append({{$varNameSingular}}PrimaryKeyColumns, update...)
|
whitelist = append({{$varNameSingular}}PrimaryKeyColumns, update...)
|
||||||
|
|
Loading…
Reference in a new issue