From 7883c25eb05b7c4efab4c13272051b764582cc67 Mon Sep 17 00:00:00 2001 From: "yemin.li" Date: Tue, 28 Mar 2023 20:47:16 -0400 Subject: [PATCH 1/2] batch bind struct map --- batchx.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/batchx.go b/batchx.go index 39825b6..498e154 100644 --- a/batchx.go +++ b/batchx.go @@ -26,6 +26,17 @@ func (b *Batch) BindStruct(qry *Queryx, arg interface{}) error { return nil } +// BindStructMap binds query named parameters to values from arg0 and arg1 using a mapper. +// If value cannot be found an error is reported. +func (b *Batch) BindStructMap(qry *Queryx, arg0 interface{}, arg1 map[string]interface{}) error { + args, err := qry.bindStructArgs(arg0, arg1) + if err != nil { + return err + } + b.Query(qry.Statement(), args...) + return nil +} + // ExecuteBatch executes a batch operation and returns nil if successful // otherwise an error describing the failure. func (s *Session) ExecuteBatch(batch *Batch) error { From eeaa76fa5ae9a71825ec7519a0ced19cd6ac7241 Mon Sep 17 00:00:00 2001 From: "yemin.li" Date: Tue, 28 Mar 2023 20:56:50 -0400 Subject: [PATCH 2/2] batch bind map --- batchx.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/batchx.go b/batchx.go index 498e154..74ba6fa 100644 --- a/batchx.go +++ b/batchx.go @@ -26,6 +26,17 @@ func (b *Batch) BindStruct(qry *Queryx, arg interface{}) error { return nil } +// BindMap binds query named parameters to values from arg using a mapper. +// If value cannot be found an error is reported. +func (b *Batch) BindMap(qry *Queryx, arg map[string]interface{}) error { + args, err := qry.bindMapArgs(arg) + if err != nil { + return err + } + b.Query(qry.Statement(), args...) + return nil +} + // BindStructMap binds query named parameters to values from arg0 and arg1 using a mapper. // If value cannot be found an error is reported. func (b *Batch) BindStructMap(qry *Queryx, arg0 interface{}, arg1 map[string]interface{}) error {