Skip to content

Commit ec7f403

Browse files
committed
remove unused code
1 parent 3912cb0 commit ec7f403

5 files changed

Lines changed: 2 additions & 100 deletions

File tree

api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type QuickSql interface {
8181
// fmt.Sprintf("select * from table_name where id=? in (%s)", qsql.StmtWhereIn(1,len(args))
8282
//
8383
// Return "?,?,?,?..." for default, or "@p1,@p2,@p3..." for mssql, or ":1,:2,:3..." for pgsql when paramStartIdx is 0.
84-
MakeStmtIn(paramStartIdx, paramLen int) string
84+
StmtIn(paramStartIdx, paramLen int) string
8585

8686
// auto commit when the func is return nil, or auto rollback when the func is error
8787
Commit(tx *sql.Tx, fn func() error) error

db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (db *DB) QueryPageMapContext(ctx context.Context, querySql string, args ...
112112

113113
// Return "?,?,?,?..." for default, or "@p1,@p2,@p3..." for mssql, or ":1,:2,:3..." for pgsql.
114114
// paramStartIdx default is 0, but you need count it when the driver is mssq, pgsql etc. .
115-
func (db *DB) MakeStmtIn(paramStartIdx, paramsLen int) string {
115+
func (db *DB) StmtIn(paramStartIdx, paramsLen int) string {
116116
return stmtIn(paramStartIdx, paramsLen, db.DriverName())
117117
}
118118

stmt_in.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package qsql
22

33
import (
44
"fmt"
5-
"reflect"
65
)
76

87
func stmtIn(paramIdx, paramsLen int, driverNames ...string) string {
@@ -46,20 +45,3 @@ func stmtIn(paramIdx, paramsLen int, driverNames ...string) string {
4645
return string(result)
4746
}
4847
}
49-
50-
func StmtSliceArgs(args ...interface{}) []interface{} {
51-
result := []interface{}{}
52-
for _, arg := range args {
53-
val := reflect.ValueOf(arg)
54-
switch val.Kind() {
55-
case reflect.Array, reflect.Slice:
56-
arrLen := val.Len()
57-
for i := 0; i < arrLen; i++ {
58-
result = append(result, val.Index(i).Interface())
59-
}
60-
default:
61-
result = append(result, arg)
62-
}
63-
}
64-
return result
65-
}

stmt_in_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,3 @@ func TestStmtIn(t *testing.T) {
2424
t.Fatalf("expect '@p1,@p2,@p3', but@ %s", msOutput1)
2525
}
2626
}
27-
28-
func TestStmtSliceArgs(t *testing.T) {
29-
in := []string{"a", "b", "c"}
30-
out := StmtSliceArgs(in)
31-
if len(out) != 3 {
32-
t.Fatalf("expect 3, but:%d", len(out))
33-
}
34-
arg1, ok := out[0].(string)
35-
if !ok {
36-
t.Fatal("expect string, but not")
37-
}
38-
if arg1 != "a" {
39-
t.Fatalf("expect 'a' , but: %s ", arg1)
40-
}
41-
}

type.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,11 @@
11
package qsql
22

33
import (
4-
"database/sql"
5-
"database/sql/driver"
64
"fmt"
75
"strconv"
86
"time"
97
)
108

11-
// Bool type
12-
type Bool bool
13-
14-
func (v *Bool) Scan(i interface{}) error {
15-
b := sql.NullBool{}
16-
if err := b.Scan(i); err != nil {
17-
return err
18-
}
19-
*v = Bool(b.Bool)
20-
return nil
21-
}
22-
func (v *Bool) Value() (driver.Value, error) {
23-
return v, nil
24-
}
25-
26-
// Int64 type
27-
type Int64 int64
28-
29-
func (v *Int64) Scan(i interface{}) error {
30-
b := sql.NullInt64{}
31-
if err := b.Scan(i); err != nil {
32-
return err
33-
}
34-
*v = Int64(b.Int64)
35-
return nil
36-
}
37-
func (v Int64) Value() (driver.Value, error) {
38-
return int64(v), nil
39-
}
40-
41-
// Float64 type
42-
type Float64 float64
43-
44-
func (v *Float64) Scan(i interface{}) error {
45-
b := sql.NullFloat64{}
46-
if err := b.Scan(i); err != nil {
47-
return err
48-
}
49-
*v = Float64(b.Float64)
50-
return nil
51-
}
52-
func (v Float64) Value() (driver.Value, error) {
53-
return float64(v), nil
54-
}
55-
56-
// String type
57-
type String string
58-
59-
func (v *String) Scan(i interface{}) error {
60-
b := sql.NullString{}
61-
if err := b.Scan(i); err != nil {
62-
return err
63-
}
64-
*v = String(b.String)
65-
return nil
66-
}
67-
func (v String) Value() (driver.Value, error) {
68-
return string(v), nil
69-
}
70-
func (v *String) String() string {
71-
return string(*v)
72-
}
73-
749
// 通用的字符串查询
7510
type DBData string
7611

0 commit comments

Comments
 (0)