Skip to content

Commit

Permalink
added batched inserts
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed May 20, 2018
1 parent 90e1824 commit 7afea39
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 100 deletions.
1 change: 1 addition & 0 deletions api.go
Expand Up @@ -25,6 +25,7 @@ type RecordMapper interface {
type ParametrizedSQL struct {
SQL string //Sql
Values []interface{} //binding parameter values
Type int
}

//DmlProvider represents dml generator, which is responsible for providing parametrized sql, it takes operation type:
Expand Down
3 changes: 3 additions & 0 deletions dml_builder.go
Expand Up @@ -47,17 +47,20 @@ func (b *DmlBuilder) GetParametrizedSQL(sqlType int, valueProvider func(column s
return &ParametrizedSQL{
SQL: b.InsertSQL,
Values: b.readInsertValues(valueProvider),
Type: SQLTypeInsert,
}

case SQLTypeUpdate:
return &ParametrizedSQL{
SQL: b.UpdateSQL,
Values: b.readValues(*b.Columns, valueProvider),
Type: SQLTypeUpdate,
}
case SQLTypeDelete:
return &ParametrizedSQL{
SQL: b.DeleteSQL,
Values: b.readValues(b.TableDescriptor.PkColumns, valueProvider),
Type: SQLTypeDelete,
}
}
panic(fmt.Sprintf("Unsupprted sqltype:%v", sqlType))
Expand Down

0 comments on commit 7afea39

Please sign in to comment.