This repository was archived by the owner on Apr 24, 2025. It is now read-only.
forked from xwb1989/sqlparser
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsqltypes.patch
290 lines (258 loc) · 11.4 KB
/
sqltypes.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
Only in /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/: arithmetic.go
Only in /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/: arithmetic_test.go
diff -u /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/bind_variables.go /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/bind_variables.go
--- /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/bind_variables.go 2018-06-05 08:45:47.000000000 -0700
+++ /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/bind_variables.go 2018-06-04 08:05:24.000000000 -0700
@@ -19,11 +19,10 @@
import (
"errors"
"fmt"
+ "reflect"
"strconv"
- "github.com/golang/protobuf/proto"
-
- querypb "vitess.io/vitess/go/vt/proto/query"
+ "github.com/xwb1989/sqlparser/dependency/querypb"
)
// NullBindVariable is a bindvar with NULL value.
@@ -253,9 +252,8 @@
}
// BindVariablesEqual compares two maps of bind variables.
-// For protobuf messages we have to use "proto.Equal".
func BindVariablesEqual(x, y map[string]*querypb.BindVariable) bool {
- return proto.Equal(&querypb.BoundQuery{BindVariables: x}, &querypb.BoundQuery{BindVariables: y})
+ return reflect.DeepEqual(&querypb.BoundQuery{BindVariables: x}, &querypb.BoundQuery{BindVariables: y})
}
// CopyBindVariables returns a shallow-copy of the given bindVariables map.
diff -u /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/bind_variables_test.go /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/bind_variables_test.go
--- /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/bind_variables_test.go 2018-06-05 08:45:47.000000000 -0700
+++ /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/bind_variables_test.go 2018-06-04 08:05:24.000000000 -0700
@@ -21,16 +21,14 @@
"strings"
"testing"
- "github.com/golang/protobuf/proto"
-
- querypb "vitess.io/vitess/go/vt/proto/query"
+ "github.com/xwb1989/sqlparser/dependency/querypb"
)
func TestProtoConversions(t *testing.T) {
v := TestValue(Int64, "1")
got := ValueToProto(v)
want := &querypb.Value{Type: Int64, Value: []byte("1")}
- if !proto.Equal(got, want) {
+ if !reflect.DeepEqual(got, want) {
t.Errorf("ValueToProto: %v, want %v", got, want)
}
gotback := ProtoToValue(got)
@@ -240,7 +238,7 @@
t.Errorf("ToBindVar(%T(%v)) error: nil, want %s", tcase.in, tcase.in, tcase.err)
continue
}
- if !proto.Equal(bv, tcase.out) {
+ if !reflect.DeepEqual(bv, tcase.out) {
t.Errorf("ToBindVar(%T(%v)): %v, want %s", tcase.in, tcase.in, bv, tcase.out)
}
}
@@ -523,7 +521,7 @@
v, err = BindVariableToValue(&querypb.BindVariable{Type: querypb.Type_TUPLE})
wantErr := "cannot convert a TUPLE bind var into a value"
if err == nil || err.Error() != wantErr {
- t.Errorf(" BindVarToValue(TUPLE): (%v, %v), want %s", v, err, wantErr)
+ t.Errorf(" BindVarToValue(TUPLE): %v, want %s", err, wantErr)
}
}
Only in /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/: event_token.go
Only in /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/: event_token_test.go
diff -u /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/plan_value.go /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/plan_value.go
--- /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/plan_value.go 2018-06-05 08:45:47.000000000 -0700
+++ /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/plan_value.go 2018-06-04 08:05:24.000000000 -0700
@@ -18,10 +18,10 @@
import (
"encoding/json"
+ "errors"
+ "fmt"
- querypb "vitess.io/vitess/go/vt/proto/query"
- vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
- "vitess.io/vitess/go/vt/vterrors"
+ "github.com/xwb1989/sqlparser/dependency/querypb"
)
// PlanValue represents a value or a list of values for
@@ -87,7 +87,7 @@
case pv.ListKey != "" || pv.Values != nil:
// This code is unreachable because the parser does not allow
// multi-value constructs where a single value is expected.
- return NULL, vterrors.New(vtrpcpb.Code_INVALID_ARGUMENT, "a list was supplied where a single value was expected")
+ return NULL, errors.New("a list was supplied where a single value was expected")
}
return NULL, nil
}
@@ -95,10 +95,10 @@
func (pv PlanValue) lookupValue(bindVars map[string]*querypb.BindVariable) (*querypb.BindVariable, error) {
bv, ok := bindVars[pv.Key]
if !ok {
- return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "missing bind var %s", pv.Key)
+ return nil, fmt.Errorf("missing bind var %s", pv.Key)
}
if bv.Type == querypb.Type_TUPLE {
- return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "TUPLE was supplied for single value bind var %s", pv.ListKey)
+ return nil, fmt.Errorf("TUPLE was supplied for single value bind var %s", pv.ListKey)
}
return bv, nil
}
@@ -129,16 +129,16 @@
}
// This code is unreachable because the parser does not allow
// single value constructs where multiple values are expected.
- return nil, vterrors.New(vtrpcpb.Code_INVALID_ARGUMENT, "a single value was supplied where a list was expected")
+ return nil, errors.New("a single value was supplied where a list was expected")
}
func (pv PlanValue) lookupList(bindVars map[string]*querypb.BindVariable) (*querypb.BindVariable, error) {
bv, ok := bindVars[pv.ListKey]
if !ok {
- return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "missing bind var %s", pv.ListKey)
+ return nil, fmt.Errorf("missing bind var %s", pv.ListKey)
}
if bv.Type != querypb.Type_TUPLE {
- return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "single value was supplied for TUPLE bind var %s", pv.ListKey)
+ return nil, fmt.Errorf("single value was supplied for TUPLE bind var %s", pv.ListKey)
}
return bv, nil
}
@@ -171,7 +171,7 @@
case l:
return nil
default:
- return vterrors.New(vtrpcpb.Code_INVALID_ARGUMENT, "mismatch in number of column values")
+ return errors.New("mismatch in number of column values")
}
}
@@ -221,7 +221,7 @@
rows[i] = make([]Value, len(pvs))
}
- // Using j because we're resolving by columns.
+ // Using j becasue we're resolving by columns.
for j, pv := range pvs {
switch {
case pv.Key != "":
diff -u /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/plan_value_test.go /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/plan_value_test.go
--- /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/plan_value_test.go 2018-06-05 08:45:47.000000000 -0700
+++ /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/plan_value_test.go 2018-06-04 08:05:24.000000000 -0700
@@ -21,7 +21,7 @@
"strings"
"testing"
- querypb "vitess.io/vitess/go/vt/proto/query"
+ "github.com/xwb1989/sqlparser/dependency/querypb"
)
func TestPlanValueIsNull(t *testing.T) {
Only in /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/: proto3.go
Only in /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/: proto3_test.go
Only in /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/: query_response.go
Only in /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/: result.go
Only in /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/: result_test.go
diff -u /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/testing.go /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/testing.go
--- /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/testing.go 2018-06-05 08:45:47.000000000 -0700
+++ /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/testing.go 2018-06-04 08:06:27.000000000 -0700
@@ -17,17 +17,14 @@
package sqltypes
import (
- "bytes"
- "fmt"
- "strings"
-
- querypb "vitess.io/vitess/go/vt/proto/query"
+ querypb "github.com/xwb1989/sqlparser/dependency/querypb"
)
// Functions in this file should only be used for testing.
// This is an experiment to see if test code bloat can be
// reduced and readability improved.
+/*
// MakeTestFields builds a []*querypb.Field for testing.
// fields := sqltypes.MakeTestFields(
// "a|b",
@@ -110,6 +107,7 @@
}
return results
}
+*/
// TestBindVariable makes a *querypb.BindVariable from
// an interface{}.It panics on invalid input.
@@ -131,6 +129,7 @@
return MakeTrusted(typ, []byte(val))
}
+/*
// PrintResults prints []*Results into a string.
// This function should only be used for testing.
func PrintResults(results []*Result) string {
@@ -152,3 +151,4 @@
}
return splits
}
+*/
diff -u /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/type.go /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/type.go
--- /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/type.go 2018-06-05 08:45:47.000000000 -0700
+++ /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/type.go 2018-06-04 08:05:24.000000000 -0700
@@ -19,7 +19,7 @@
import (
"fmt"
- querypb "vitess.io/vitess/go/vt/proto/query"
+ "github.com/xwb1989/sqlparser/dependency/querypb"
)
// This file provides wrappers and support
diff -u /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/type_test.go /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/type_test.go
--- /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/type_test.go 2018-06-05 08:45:47.000000000 -0700
+++ /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/type_test.go 2018-06-04 08:05:24.000000000 -0700
@@ -19,7 +19,7 @@
import (
"testing"
- querypb "vitess.io/vitess/go/vt/proto/query"
+ "github.com/xwb1989/sqlparser/dependency/querypb"
)
func TestTypeValues(t *testing.T) {
diff -u /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/value.go /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/value.go
--- /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/value.go 2018-06-05 08:45:47.000000000 -0700
+++ /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/value.go 2018-06-04 08:05:24.000000000 -0700
@@ -23,10 +23,10 @@
"fmt"
"strconv"
- "vitess.io/vitess/go/bytes2"
- "vitess.io/vitess/go/hack"
+ "github.com/xwb1989/sqlparser/dependency/bytes2"
+ "github.com/xwb1989/sqlparser/dependency/hack"
- querypb "vitess.io/vitess/go/vt/proto/query"
+ "github.com/xwb1989/sqlparser/dependency/querypb"
)
var (
@@ -48,7 +48,7 @@
}
// Value can store any SQL value. If the value represents
-// an integral type, the bytes are always stored as a canonical
+// an integral type, the bytes are always stored as a cannonical
// representation that matches how MySQL returns such values.
type Value struct {
typ querypb.Type
@@ -126,7 +126,7 @@
return MakeTrusted(VarBinary, []byte(v))
}
-// NewIntegral builds an integral type from a string representation.
+// NewIntegral builds an integral type from a string representaion.
// The type will be Int64 or Uint64. Int64 will be preferred where possible.
func NewIntegral(val string) (n Value, err error) {
signed, err := strconv.ParseInt(val, 0, 64)
@@ -169,7 +169,7 @@
return v.typ
}
-// Raw returns the internal representation of the value. For newer types,
+// Raw returns the internal represenation of the value. For newer types,
// this may not match MySQL's representation.
func (v Value) Raw() []byte {
return v.val
diff -u /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/value_test.go /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/value_test.go
--- /Users/bramp/go/src/vitess.io/vitess/go//sqltypes/value_test.go 2018-06-05 08:45:47.000000000 -0700
+++ /Users/bramp/go/src/github.com/xwb1989/sqlparser//dependency/sqltypes/value_test.go 2018-06-04 08:05:24.000000000 -0700
@@ -22,7 +22,7 @@
"strings"
"testing"
- querypb "vitess.io/vitess/go/vt/proto/query"
+ "github.com/xwb1989/sqlparser/dependency/querypb"
)
const (