From 7f9e42fed621d62eefb2d307dda588d59cb0f48a Mon Sep 17 00:00:00 2001 From: zhenghaorong Date: Tue, 24 Sep 2024 11:49:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djoin=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=BD=BF=E7=94=A8with=E4=B8=B4=E6=97=B6=E8=A1=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chain.go | 4 +--- db.go | 9 +++------ transaction_chain.go | 6 +----- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/chain.go b/chain.go index 8bc4367..fb66d75 100644 --- a/chain.go +++ b/chain.go @@ -291,7 +291,6 @@ func (this *Query) BuildSelectSql() (map[string]interface{}, error) { withSql := "" if len(this.with) > 0 { var builder strings.Builder - builder.Reset() builder.WriteString("WITH ") boo := false for k, v := range this.with { @@ -352,12 +351,11 @@ func (this *Query) BuildSelectSql() (map[string]interface{}, error) { if len(this.join) > 0 { var builder strings.Builder - builder.Reset() + builder.WriteString(sql) for _, joinitem := range this.join { if len(joinitem) < 2 { continue } - builder.WriteString(sql) builder.WriteString(" ") if len(joinitem) >= 3 { builder.WriteString(joinitem[2]) diff --git a/db.go b/db.go index 32d6c77..20f729a 100644 --- a/db.go +++ b/db.go @@ -307,7 +307,6 @@ func GetRow(dbName, table_name, alias string, titles string, with, join [][]stri withSql := "" if len(with) > 0 { var builder strings.Builder - builder.Reset() builder.WriteString("WITH ") boo := false for k, v := range with { @@ -354,12 +353,11 @@ func GetRow(dbName, table_name, alias string, titles string, with, join [][]stri if len(join) > 0 { var builder strings.Builder - builder.Reset() + builder.WriteString(sql_str) for _, joinitem := range join { if len(joinitem) < 2 { continue } - builder.WriteString(sql_str) builder.WriteString(" ") if len(joinitem) >= 3 { builder.WriteString(joinitem[2]) @@ -498,7 +496,6 @@ func FetchRows(dbName, table_name, alias string, titles string, with, join [][]s withSql := "" if len(with) > 0 { var builder strings.Builder - builder.Reset() builder.WriteString("WITH ") boo := false for k, v := range with { @@ -546,12 +543,12 @@ func FetchRows(dbName, table_name, alias string, titles string, with, join [][]s if len(join) > 0 { var builder strings.Builder - builder.Reset() + builder.WriteString(sql_str) for _, joinitem := range join { if len(joinitem) < 2 { continue } - builder.WriteString(sql_str) + builder.WriteString(" ") if len(joinitem) >= 3 { builder.WriteString(joinitem[2]) diff --git a/transaction_chain.go b/transaction_chain.go index 9686a04..ce48b9d 100644 --- a/transaction_chain.go +++ b/transaction_chain.go @@ -225,7 +225,6 @@ func (this *TxQuery) BuildSelectSql() (map[string]interface{}, error) { withSql := "" if len(this.with) > 0 { var builder strings.Builder - builder.Reset() builder.WriteString("WITH ") boo := false for k, v := range this.with { @@ -270,14 +269,11 @@ func (this *TxQuery) BuildSelectSql() (map[string]interface{}, error) { if len(this.join) > 0 { var builder strings.Builder - builder.Reset() + builder.WriteString(sql) for _, joinitem := range this.join { if len(joinitem) < 2 { continue } - builder.WriteString(sql) - builder.WriteString(" ") - builder.WriteString(sql) builder.WriteString(" ") if len(joinitem) >= 3 { builder.WriteString(joinitem[2])