From ae0d5506c1345a8782558ded656b5950ef793699 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 30 Jun 2021 11:24:47 +0800 Subject: [PATCH] Remove unrelated files --- convert/time.go | 30 ------------------------------ scan.go | 48 ------------------------------------------------ 2 files changed, 78 deletions(-) delete mode 100644 convert/time.go diff --git a/convert/time.go b/convert/time.go deleted file mode 100644 index 8901279b..00000000 --- a/convert/time.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2021 The Xorm Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package convert - -import ( - "fmt" - "time" -) - -// String2Time converts a string to time with original location -func String2Time(s string, originalLocation *time.Location, convertedLocation *time.Location) (*time.Time, error) { - if len(s) == 19 { - dt, err := time.ParseInLocation("2006-01-02 15:04:05", s, originalLocation) - if err != nil { - return nil, err - } - dt = dt.In(convertedLocation) - return &dt, nil - } else if len(s) == 20 && s[10] == 'T' && s[19] == 'Z' { - dt, err := time.ParseInLocation("2006-01-02T15:04:05Z", s, originalLocation) - if err != nil { - return nil, err - } - dt = dt.In(convertedLocation) - return &dt, nil - } - return nil, fmt.Errorf("unsupported convertion from %s to time", s) -} diff --git a/scan.go b/scan.go index 32c97c3d..39836669 100644 --- a/scan.go +++ b/scan.go @@ -6,58 +6,10 @@ package xorm import ( "database/sql" - "time" - "xorm.io/xorm/convert" "xorm.io/xorm/core" ) -func (engine *Engine) scan(rows *core.Rows, types []*sql.ColumnType, v ...interface{}) error { - var v2 = make([]interface{}, 0, len(v)) - var turnBackIdxes = make([]int, 0, 5) - for i, vv := range v { - switch vv.(type) { - case *time.Time: - v2 = append(v2, &sql.NullString{}) - turnBackIdxes = append(turnBackIdxes, i) - case *sql.NullTime: - v2 = append(v2, &sql.NullString{}) - turnBackIdxes = append(turnBackIdxes, i) - default: - v2 = append(v2, v[i]) - } - } - if err := rows.Scan(v2...); err != nil { - return err - } - for _, i := range turnBackIdxes { - switch t := v[i].(type) { - case *time.Time: - var s = *(v2[i].(*sql.NullString)) - if !s.Valid { - break - } - dt, err := convert.String2Time(s.String, engine.DatabaseTZ, engine.TZLocation) - if err != nil { - return err - } - *t = *dt - case *sql.NullTime: - var s = *(v2[i].(*sql.NullString)) - if !s.Valid { - break - } - dt, err := convert.String2Time(s.String, engine.DatabaseTZ, engine.TZLocation) - if err != nil { - return err - } - t.Time = *dt - t.Valid = true - } - } - return nil -} - func (engine *Engine) row2mapStr(rows *core.Rows, types []*sql.ColumnType, fields []string) (map[string]string, error) { var scanResults = make([]interface{}, len(fields)) for i := 0; i < len(fields); i++ {