github.com/team-ide/go-dialect@v1.9.20/dialect/dialect_test.go (about)

     1  package dialect
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestInsertDataList(t *testing.T) {
     9  	dia, err := NewDialect("oracle")
    10  	if err != nil {
    11  		return
    12  	}
    13  	param := &ParamModel{}
    14  	var columnList = []*ColumnModel{
    15  		{ColumnName: "name"},
    16  		{ColumnName: "age"},
    17  		{ColumnName: "account"},
    18  	}
    19  	var dataList = []map[string]interface{}{
    20  		{"name": "名称1", "age": 1},
    21  		{"name": "名称2", "age": 11},
    22  		{"name": "名称3", "age": 11, "account": "name3"},
    23  	}
    24  	sqlList, valuesList, batchSqlList, batchValuesList, err := dia.DataListInsertSql(param, "TEST_DB", "USER_INFO", columnList, dataList)
    25  	fmt.Println("--------sql list--------")
    26  	for index := range sqlList {
    27  		fmt.Println("sql:", sqlList[index])
    28  		fmt.Println("values:", valuesList[index])
    29  	}
    30  	fmt.Println("--------batch sql list--------")
    31  	for index := range batchSqlList {
    32  		fmt.Println("batchSq:", batchSqlList[index])
    33  		fmt.Println("batchValues:", batchValuesList[index])
    34  	}
    35  }