diff --git a/templates/16_update.tpl b/templates/16_update.tpl index f84a35c..6dd8690 100644 --- a/templates/16_update.tpl +++ b/templates/16_update.tpl @@ -157,12 +157,23 @@ func (o {{$tableNameSingular}}Slice) UpdateAll(exec boil.Executor, cols M) error pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), {{$varNameSingular}}PrimaryKeyMapping) args = append(args, pkeyArgs...) } - + {{if ne .DriverName "mssql" -}} sql := fmt.Sprintf( "UPDATE {{$schemaTable}} SET %s WHERE ({{.LQ}}{{.Table.PKey.Columns | join (printf "%s,%s" .LQ .RQ)}}{{.RQ}}) IN (%s)", strmangle.SetParamNames("{{.LQ}}", "{{.RQ}}", {{if .Dialect.IndexPlaceholders}}1{{else}}0{{end}}, colNames), strmangle.Placeholders(dialect.IndexPlaceholders, len(o) * len({{$varNameSingular}}PrimaryKeyColumns), len(colNames)+1, len({{$varNameSingular}}PrimaryKeyColumns)), ) + {{- else -}} + startIndex := len(colNames) + 1 + + if !dialect.IndexPlaceholders { + startIndex = 0 + } + + sql := fmt.Sprintf("UPDATE {{$schemaTable}} SET %s WHERE %s", + strmangle.SetParamNames("{{.LQ}}", "{{.RQ}}", {{if .Dialect.IndexPlaceholders}}1{{else}}0{{end}}, colNames), + strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), startIndex, {{$varNameSingular}}PrimaryKeyColumns, len(o))) + {{- end}} if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, sql) diff --git a/templates/19_reload.tpl b/templates/19_reload.tpl index 45c0e61..ff656f1 100644 --- a/templates/19_reload.tpl +++ b/templates/19_reload.tpl @@ -79,11 +79,22 @@ 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}} q := queries.Raw(exec, sql, args...)