Browse Source

解决append乱序

master
zhenghaorong 2 years ago
parent
commit
0ccf9774b7
2 changed files with 12 additions and 8 deletions
  1. +6
    -4
      chain.go
  2. +6
    -4
      transaction_chain.go

+ 6
- 4
chain.go View File

@ -344,12 +344,14 @@ func (this *Query) CreateAllStmt() error {
this.data = []string{} this.data = []string{}
this.value = []interface{}{} this.value = []interface{}{}
for i, datum := range this.save_data { for i, datum := range this.save_data {
for s, v := range datum {
if i == 0 {
this.data = append(this.data, s)
if i == 0 {
for k, _ := range datum {
this.data = append(this.data, k)
dataSql = append(dataSql, "?") dataSql = append(dataSql, "?")
} }
this.value = append(this.value, v)
}
for _, k := range this.data {
this.value = append(this.value, datum[k])
} }
valSql = append(valSql, "("+strings.Join(dataSql, " , ")+")") valSql = append(valSql, "("+strings.Join(dataSql, " , ")+")")
} }


+ 6
- 4
transaction_chain.go View File

@ -378,12 +378,14 @@ func (this *TxQuery) CreateAllStmt() error {
this.data = []string{} this.data = []string{}
this.value = []interface{}{} this.value = []interface{}{}
for i, datum := range this.save_data { for i, datum := range this.save_data {
for s, v := range datum {
if i == 0 {
this.data = append(this.data, s)
if i == 0 {
for k, _ := range datum {
this.data = append(this.data, k)
dataSql = append(dataSql, "?") dataSql = append(dataSql, "?")
} }
this.value = append(this.value, v)
}
for _, k := range this.data {
this.value = append(this.value, datum[k])
} }
valSql = append(valSql, "("+strings.Join(dataSql, " , ")+")") valSql = append(valSql, "("+strings.Join(dataSql, " , ")+")")
} }


Loading…
Cancel
Save