Skip to content

Commit

Permalink
chore(inserter): adding a parameter to specify the include pk field f…
Browse files Browse the repository at this point in the history
…or the inserter (#109)

adding a parameter to specify the include pk field for the inserter
  • Loading branch information
Jacobbrewer1 authored Feb 6, 2025
1 parent 046fccd commit 209d8ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions inserter/batch_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion inserter/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 209d8ec

Please sign in to comment.