improve clickhouse driver

This commit is contained in:
daguang
2022-02-19 17:49:53 +08:00
parent daf2b649ef
commit ea60f7e054
4 changed files with 67 additions and 12 deletions

View File

@ -242,8 +242,9 @@ type Sql struct {
type DoInsertOption struct {
OnDuplicateStr string
OnDuplicateMap map[string]interface{}
InsertOption int // Insert operation.
BatchCount int // Batch count for batch inserting.
InsertOption int // Insert operation.
BatchCount int // Batch count for batch inserting.
IsIgnoreResult bool // IgnoreResult
}
// TableField is the struct for table field.

View File

@ -450,12 +450,14 @@ func (c *Core) DoInsert(ctx context.Context, link Link, table string, list List,
if err != nil {
return stdSqlResult, err
}
if affectedRows, err = stdSqlResult.RowsAffected(); err != nil {
err = gerror.WrapCode(gcode.CodeDbOperationError, err, `sql.Result.RowsAffected failed`)
return stdSqlResult, err
} else {
batchResult.Result = stdSqlResult
batchResult.Affected += affectedRows
if !option.IsIgnoreResult {
if affectedRows, err = stdSqlResult.RowsAffected(); err != nil {
err = gerror.WrapCode(gcode.CodeDbOperationError, err, `sql.Result.RowsAffected failed`)
return stdSqlResult, err
} else {
batchResult.Result = stdSqlResult
batchResult.Affected += affectedRows
}
}
params = params[:0]
valueHolder = valueHolder[:0]