This commit is contained in:
Lunny Xiao 2023-10-19 15:55:30 +08:00
parent 30667e9d38
commit 3aca84268c
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
4 changed files with 9 additions and 11 deletions

View File

@ -89,7 +89,7 @@ func (statement *Statement) GenInsertSQL(colNames []string, args []interface{})
}
if statement.Conds().IsValid() {
if err := statement.writeString(" SELECT ")(buf); err != nil {
if err := statement.writeStrings(" SELECT ")(buf); err != nil {
return "", nil, err
}

View File

@ -18,7 +18,7 @@ func (statement *Statement) isUsingLegacyLimitOffset() bool {
// write mssql legacy query sql
func (statement *Statement) writeMssqlLegacySelect(buf *builder.BytesWriter, columnStr string) error {
return statement.writeMultiple(buf,
statement.writeString("SELECT"),
statement.writeStrings("SELECT"),
statement.writeDistinct,
statement.writeTop,
statement.writeFrom,

View File

@ -249,9 +249,9 @@ func (statement *Statement) writeDistinct(w *builder.BytesWriter) error {
func (statement *Statement) writeSelectColumns(columnStr string) func(w *builder.BytesWriter) error {
return statement.groupWriteFns(
statement.writeString("SELECT"),
statement.writeStrings("SELECT"),
statement.writeDistinct,
statement.writeString(columnStr),
statement.writeStrings(" ", columnStr),
)
}

View File

@ -10,19 +10,17 @@ import (
"xorm.io/builder"
)
func (statement *Statement) writeString(str string) func(w *builder.BytesWriter) error {
func (statement *Statement) writeStrings(strs ...string) func(w *builder.BytesWriter) error {
return func(w *builder.BytesWriter) error {
for _, str := range strs {
if _, err := fmt.Fprint(w, str); err != nil {
return err
}
}
return nil
}
}
func (statement *Statement) writeSpace(w *builder.BytesWriter) error {
return statement.writeString(" ")(w)
}
func (statement *Statement) groupWriteFns(writeFuncs ...func(*builder.BytesWriter) error) func(*builder.BytesWriter) error {
return func(bw *builder.BytesWriter) error {
return statement.writeMultiple(bw, writeFuncs...)