Skip to content

Commit

Permalink
Merge pull request #264 from noborus/fix-multi
Browse files Browse the repository at this point in the history
Fixed flag set for multiple queries
  • Loading branch information
noborus authored Dec 12, 2023
2 parents a5fc44c + a47fd1f commit df03fb0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type WriteFormat struct {
func NewExporter(writer Writer) *WriteFormat {
return &WriteFormat{
Writer: writer,
multi: false,
}
}

Expand All @@ -42,11 +43,11 @@ func (e *WriteFormat) Export(db *DB, sql string) error {
// ExportContext is called from ExecContext.
func (e *WriteFormat) ExportContext(ctx context.Context, db *DB, sqlQuery string) error {
queries := sqlss.SplitQueries(sqlQuery)
e.multi = false
if !multi || len(queries) == 1 {
e.multi = true
return e.exportContext(ctx, db, sqlQuery)
}

e.multi = true
for _, query := range queries {
if err := e.exportContext(ctx, db, query); err != nil {
return err
Expand Down

0 comments on commit df03fb0

Please sign in to comment.