diff --git a/inserter/batch_opts.go b/inserter/batch_opts.go index 53984bd..49fc19e 100644 --- a/inserter/batch_opts.go +++ b/inserter/batch_opts.go @@ -44,8 +44,8 @@ func WithIgnoreFieldsFunc(f patcher.IgnoreFieldsFunc) BatchOpt { } // WithIncludePrimaryKey determines whether the primary key should be included in the insert -func WithIncludePrimaryKey() BatchOpt { +func WithIncludePrimaryKey(includePrimaryKey bool) BatchOpt { return func(b *SQLBatch) { - b.includePrimaryKey = true + b.includePrimaryKey = includePrimaryKey } } diff --git a/inserter/sql_test.go b/inserter/sql_test.go index cbb8710..bae25f4 100644 --- a/inserter/sql_test.go +++ b/inserter/sql_test.go @@ -88,7 +88,7 @@ func (s *newBatchSuite) TestNewBatch_Success_IncludePK() { &temp{ID: 5, Name: "test5", unexported: "test"}, } - b := NewBatch(resources, WithTable("temp"), WithTagName("db"), WithIncludePrimaryKey()) + b := NewBatch(resources, WithTable("temp"), WithTagName("db"), WithIncludePrimaryKey(true)) s.Require().Len(b.Fields(), 2) s.Require().Len(b.Args(), 10)