Generic Select statement in Reload

This commit is contained in:
Sergey Kurt 2017-04-01 21:11:01 +03:00
parent f913d5e791
commit b2acda8ade

View file

@ -79,22 +79,8 @@ func (o *{{$tableNameSingular}}Slice) ReloadAll(exec boil.Executor) error {
args = append(args, pkeyArgs...)
}
{{if ne .DriverName "mssql" -}}
sql := fmt.Sprintf(
"SELECT {{$schemaTable}}.* FROM {{$schemaTable}} WHERE (%s) IN (%s)",
strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, {{$varNameSingular}}PrimaryKeyColumns), ","),
strmangle.Placeholders(dialect.IndexPlaceholders, len(*o) * len({{$varNameSingular}}PrimaryKeyColumns), 1, len({{$varNameSingular}}PrimaryKeyColumns)),
)
{{- else -}}
startIndex := 1
if !dialect.IndexPlaceholders {
startIndex = 0
}
sql := "SELECT {{$schemaTable}}.* FROM {{$schemaTable}} WHERE " +
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), startIndex, {{$varNameSingular}}PrimaryKeyColumns, len(*o))
{{- end}}
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), {{if .Dialect.IndexPlaceholders}}1{{else}}0{{end}}, {{$varNameSingular}}PrimaryKeyColumns, len(*o))
q := queries.Raw(exec, sql, args...)