1 Commits

Author SHA1 Message Date
  zhenghaorong c13da09c57 增加过滤 2 months ago
3 changed files with 12 additions and 5 deletions
Unified View
  1. +3
    -1
      chain.go
  2. +6
    -3
      db.go
  3. +3
    -1
      transaction_chain.go

+ 3
- 1
chain.go View File

@ -352,6 +352,7 @@ func (this *Query) BuildSelectSql() (map[string]interface{}, error) {
if len(this.join) > 0 { if len(this.join) > 0 {
var builder strings.Builder var builder strings.Builder
builder.WriteString(sql) builder.WriteString(sql)
boo := false
for _, joinitem := range this.join { for _, joinitem := range this.join {
if len(joinitem) < 2 { if len(joinitem) < 2 {
continue continue
@ -370,8 +371,9 @@ func (this *Query) BuildSelectSql() (map[string]interface{}, error) {
} }
builder.WriteString(" on ") builder.WriteString(" on ")
builder.WriteString(joinitem[1]) builder.WriteString(joinitem[1])
boo = true
} }
if builder.Len() > 0 {
if boo {
sql = builder.String() sql = builder.String()
} }
} }


+ 6
- 3
db.go View File

@ -354,6 +354,7 @@ func GetRow(dbName, table_name, alias string, titles string, with, join [][]stri
if len(join) > 0 { if len(join) > 0 {
var builder strings.Builder var builder strings.Builder
builder.WriteString(sql_str) builder.WriteString(sql_str)
boo := false
for _, joinitem := range join { for _, joinitem := range join {
if len(joinitem) < 2 { if len(joinitem) < 2 {
continue continue
@ -372,8 +373,9 @@ func GetRow(dbName, table_name, alias string, titles string, with, join [][]stri
} }
builder.WriteString(" on ") builder.WriteString(" on ")
builder.WriteString(joinitem[1]) builder.WriteString(joinitem[1])
boo = true
} }
if builder.Len() > 0 {
if boo {
sql_str = builder.String() sql_str = builder.String()
} }
} }
@ -544,11 +546,11 @@ func FetchRows(dbName, table_name, alias string, titles string, with, join [][]s
if len(join) > 0 { if len(join) > 0 {
var builder strings.Builder var builder strings.Builder
builder.WriteString(sql_str) builder.WriteString(sql_str)
boo := false
for _, joinitem := range join { for _, joinitem := range join {
if len(joinitem) < 2 { if len(joinitem) < 2 {
continue continue
} }
builder.WriteString(" ") builder.WriteString(" ")
if len(joinitem) >= 3 { if len(joinitem) >= 3 {
builder.WriteString(joinitem[2]) builder.WriteString(joinitem[2])
@ -563,8 +565,9 @@ func FetchRows(dbName, table_name, alias string, titles string, with, join [][]s
} }
builder.WriteString(" on ") builder.WriteString(" on ")
builder.WriteString(joinitem[1]) builder.WriteString(joinitem[1])
boo = true
} }
if builder.Len() > 0 {
if boo {
sql_str = builder.String() sql_str = builder.String()
} }
} }


+ 3
- 1
transaction_chain.go View File

@ -270,6 +270,7 @@ func (this *TxQuery) BuildSelectSql() (map[string]interface{}, error) {
if len(this.join) > 0 { if len(this.join) > 0 {
var builder strings.Builder var builder strings.Builder
builder.WriteString(sql) builder.WriteString(sql)
boo := false
for _, joinitem := range this.join { for _, joinitem := range this.join {
if len(joinitem) < 2 { if len(joinitem) < 2 {
continue continue
@ -288,8 +289,9 @@ func (this *TxQuery) BuildSelectSql() (map[string]interface{}, error) {
} }
builder.WriteString(" on ") builder.WriteString(" on ")
builder.WriteString(joinitem[1]) builder.WriteString(joinitem[1])
boo = true
} }
if builder.Len() > 0 {
if boo {
sql = builder.String() sql = builder.String()
} }
} }


Loading…
Cancel
Save