Browse Source

修复join无法使用with临时表问题

master v0.13.1
zhenghaorong 1 month ago
parent
commit
7f9e42fed6
3 changed files with 5 additions and 14 deletions
  1. +1
    -3
      chain.go
  2. +3
    -6
      db.go
  3. +1
    -5
      transaction_chain.go

+ 1
- 3
chain.go View File

@ -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])


+ 3
- 6
db.go View File

@ -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])


+ 1
- 5
transaction_chain.go View File

@ -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])


Loading…
Cancel
Save