...
1
2
3 package sqlmock
4
5 import (
6 "database/sql/driver"
7 "io"
8 "reflect"
9 )
10
11
12 func (rs *rowSets) HasNextResultSet() bool {
13 return rs.pos+1 < len(rs.sets)
14 }
15
16
17 func (rs *rowSets) NextResultSet() error {
18 if !rs.HasNextResultSet() {
19 return io.EOF
20 }
21
22 rs.pos++
23 return nil
24 }
25
26
27 type rowSetsWithDefinition struct {
28 *rowSets
29 }
30
31
32 func (rs *rowSetsWithDefinition) ColumnTypeDatabaseTypeName(index int) string {
33 return rs.getDefinition(index).DbType()
34 }
35
36
37 func (rs *rowSetsWithDefinition) ColumnTypeLength(index int) (length int64, ok bool) {
38 return rs.getDefinition(index).Length()
39 }
40
41
42 func (rs *rowSetsWithDefinition) ColumnTypeNullable(index int) (nullable, ok bool) {
43 return rs.getDefinition(index).IsNullable()
44 }
45
46
47 func (rs *rowSetsWithDefinition) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) {
48 return rs.getDefinition(index).PrecisionScale()
49 }
50
51
52 func (rs *rowSetsWithDefinition) ColumnTypeScanType(index int) reflect.Type {
53 return rs.getDefinition(index).ScanType()
54 }
55
56
57 func (rs *rowSetsWithDefinition) getDefinition(index int) *Column {
58 return rs.sets[rs.pos].def[index]
59 }
60
61
62 func NewRowsWithColumnDefinition(columns ...*Column) *Rows {
63 cols := make([]string, len(columns))
64 for i, column := range columns {
65 cols[i] = column.Name()
66 }
67
68 return &Rows{
69 cols: cols,
70 def: columns,
71 nextErr: make(map[int]error),
72 converter: driver.DefaultParameterConverter,
73 }
74 }
75
View as plain text