Skip to content

Commit

Permalink
moved scanner from asc
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Mar 1, 2018
1 parent e9a1f64 commit b1061d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
18 changes: 4 additions & 14 deletions scanner.go
@@ -1,5 +1,7 @@
package dsc

import "github.com/viant/toolbox"

type scanner struct {
scanner Scanner
}
Expand All @@ -9,10 +11,9 @@ func (s *scanner) Columns() ([]string, error) {
}

func (s *scanner) Scan(destinations ...interface{}) error {

if len(destinations) == 1 {

if aMap, ok := destinations[0].(map[string]interface{}); ok {
if toolbox.IsMap(destinations[0]) {
aMap := toolbox.AsMap(destinations[0])
values, columns, err := ScanRow(s)
if err != nil {
return err
Expand All @@ -21,17 +22,6 @@ func (s *scanner) Scan(destinations ...interface{}) error {
aMap[column] = values[i]
}
return nil

}
if aMap, ok := destinations[0].(*map[string]interface{}); ok {
values, columns, err := ScanRow(s)
if err != nil {
return err
}
for i, column := range columns {
(*aMap)[column] = values[i]
}
return nil
}
}
err := s.scanner.Scan(destinations...)
Expand Down
2 changes: 0 additions & 2 deletions sql_scanner.go
Expand Up @@ -38,7 +38,6 @@ func (s *SQLScanner) Scan(destinations ...interface{}) error {
return nil
}


func NewSQLScanner(query *QueryStatement, config *Config, columns []string) *SQLScanner {
converter := *toolbox.NewColumnConverter(config.GetDateLayout())
if len(columns) == 0 {
Expand All @@ -50,4 +49,3 @@ func NewSQLScanner(query *QueryStatement, config *Config, columns []string) *SQL
converter: converter,
}
}

0 comments on commit b1061d0

Please sign in to comment.