33{ {- $schemaTable := .Table.Name | .SchemaTable} }
44{ {if .AddGlobal -} }
55// UpsertG attempts an insert, and does an update or ignore on conflict.
6- func (o *{ {$alias .UpSingular} }) UpsertG({ {if not .NoContext} }ctx context.Context, { {end -} } updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) error {
7- return o.Upsert({{if .NoContext} }boil.GetDB(){ {else } }ctx, boil.GetContextDB(){ {end} }, updateOnConflict, conflictColumns, updateColumns, insertColumns)
6+ func (o *{ {$alias .UpSingular} }) UpsertG({ {if not .NoContext} }ctx context.Context, { {end -} } updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns, opts ...UpsertOptionFunc ) error {
7+ return o.Upsert({{if .NoContext} }boil.GetDB(){ {else } }ctx, boil.GetContextDB(){ {end} }, updateOnConflict, conflictColumns, updateColumns, insertColumns, opts... )
88}
99
1010{ {end -} }
1111
1212{ {if and .AddGlobal .AddPanic -} }
1313// UpsertGP attempts an insert, and does an update or ignore on conflict. Panics on error.
14- func (o *{ {$alias .UpSingular} }) UpsertGP({ {if not .NoContext} }ctx context.Context, { {end -} } updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) {
15- if err := o.Upsert({{if .NoContext} }boil.GetDB(){ {else } }ctx, boil.GetContextDB(){ {end} }, updateOnConflict, conflictColumns, updateColumns, insertColumns); err != nil {
14+ func (o *{ {$alias .UpSingular} }) UpsertGP({ {if not .NoContext} }ctx context.Context, { {end -} } updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns, opts ...UpsertOptionFunc ) {
15+ if err := o.Upsert({{if .NoContext} }boil.GetDB(){ {else } }ctx, boil.GetContextDB(){ {end} }, updateOnConflict, conflictColumns, updateColumns, insertColumns, opts... ); err != nil {
1616 panic(boil.WrapErr(err))
1717 }
1818}
@@ -22,8 +22,8 @@ func (o *{{$alias.UpSingular}}) UpsertGP({{if not .NoContext}}ctx context.Contex
2222{ {if .AddPanic -} }
2323// UpsertP attempts an insert using an executor, and does an update or ignore on conflict.
2424// UpsertP panics on error.
25- func (o *{ {$alias .UpSingular} }) UpsertP({ {if .NoContext} }exec boil.Executor{ {else } }ctx context.Context, exec boil.ContextExecutor{ {end} }, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) {
26- if err := o.Upsert({{if not .NoContext} }ctx, { {end -} } exec, updateOnConflict, conflictColumns, updateColumns, insertColumns); err != nil {
25+ func (o *{ {$alias .UpSingular} }) UpsertP({ {if .NoContext} }exec boil.Executor{ {else } }ctx context.Context, exec boil.ContextExecutor{ {end} }, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns, opts ...UpsertOptionFunc ) {
26+ if err := o.Upsert({{if not .NoContext} }ctx, { {end -} } exec, updateOnConflict, conflictColumns, updateColumns, insertColumns, opts... ); err != nil {
2727 panic(boil.WrapErr(err))
2828 }
2929}
@@ -32,7 +32,7 @@ func (o *{{$alias.UpSingular}}) UpsertP({{if .NoContext}}exec boil.Executor{{els
3232
3333// Upsert attempts an insert using an executor, and does an update or ignore on conflict.
3434// See boil.Columns documentation for how to properly use updateColumns and insertColumns.
35- func (o *{ {$alias .UpSingular} }) Upsert({ {if .NoContext} }exec boil.Executor{ {else } }ctx context.Context, exec boil.ContextExecutor{ {end} }, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) error {
35+ func (o *{ {$alias .UpSingular} }) Upsert({ {if .NoContext} }exec boil.Executor{ {else } }ctx context.Context, exec boil.ContextExecutor{ {end} }, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns, opts ...UpsertOptionFunc ) error {
3636 if o == nil {
3737 return errors.New(" {{.PkgName}}: no {{.Table.Name}} provided for upsert" )
3838 }
@@ -111,7 +111,7 @@ func (o *{{$alias.UpSingular}}) Upsert({{if .NoContext}}exec boil.Executor{{else
111111 conflict = make([]string, len({ {$alias .DownSingular} }PrimaryKeyColumns))
112112 copy(conflict, { {$alias .DownSingular} }PrimaryKeyColumns)
113113 }
114- cache.query = buildUpsertQueryPostgres(dialect, "{ {$schemaTable } }", updateOnConflict, ret, update, conflict, insert)
114+ cache.query = buildUpsertQueryPostgres(dialect, "{ {$schemaTable } }", updateOnConflict, ret, update, conflict, insert, opts... )
115115
116116 cache.valueMapping, err = queries.BindMapping({ {$alias .DownSingular} }Type, { {$alias .DownSingular} }Mapping, insert)
117117 if err != nil {
0 commit comments