Browse Source

增加过滤

master v0.13.2
zhenghaorong 3 months ago
parent
commit
c13da09c57
3 changed files with 12 additions and 5 deletions
  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 {
var builder strings.Builder
builder.WriteString(sql)
boo := false
for _, joinitem := range this.join {
if len(joinitem) < 2 {
continue
@ -370,8 +371,9 @@ func (this *Query) BuildSelectSql() (map[string]interface{}, error) {
}
builder.WriteString(" on ")
builder.WriteString(joinitem[1])
boo = true
}
if builder.Len() > 0 {
if boo {
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 {
var builder strings.Builder
builder.WriteString(sql_str)
boo := false
for _, joinitem := range join {
if len(joinitem) < 2 {
continue
@ -372,8 +373,9 @@ func GetRow(dbName, table_name, alias string, titles string, with, join [][]stri
}
builder.WriteString(" on ")
builder.WriteString(joinitem[1])
boo = true
}
if builder.Len() > 0 {
if boo {
sql_str = builder.String()
}
}
@ -544,11 +546,11 @@ func FetchRows(dbName, table_name, alias string, titles string, with, join [][]s
if len(join) > 0 {
var builder strings.Builder
builder.WriteString(sql_str)
boo := false
for _, joinitem := range join {
if len(joinitem) < 2 {
continue
}
builder.WriteString(" ")
if len(joinitem) >= 3 {
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(joinitem[1])
boo = true
}
if builder.Len() > 0 {
if boo {
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 {
var builder strings.Builder
builder.WriteString(sql)
boo := false
for _, joinitem := range this.join {
if len(joinitem) < 2 {
continue
@ -288,8 +289,9 @@ func (this *TxQuery) BuildSelectSql() (map[string]interface{}, error) {
}
builder.WriteString(" on ")
builder.WriteString(joinitem[1])
boo = true
}
if builder.Len() > 0 {
if boo {
sql = builder.String()
}
}


Loading…
Cancel
Save