Skip to content

Commit 4d1c1d4

Browse files
author
fancl
committed
fix var
1 parent 1203878 commit 4d1c1d4

25 files changed

+81
-69
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
y.output
2+
.idea

analyzer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"strings"
2626
"unicode"
2727

28-
"github.com/xwb1989/sqlparser/dependency/sqltypes"
28+
"github.com/uole/sqlparser/dependency/sqltypes"
2929
)
3030

3131
// These constants are used to identify the SQL statement type.

analyzer_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"strings"
2222
"testing"
2323

24-
"github.com/xwb1989/sqlparser/dependency/sqltypes"
24+
"github.com/uole/sqlparser/dependency/sqltypes"
2525
)
2626

2727
func TestPreview(t *testing.T) {

ast.go

+25-25
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"log"
2626
"strings"
2727

28-
"github.com/xwb1989/sqlparser/dependency/querypb"
29-
"github.com/xwb1989/sqlparser/dependency/sqltypes"
28+
"github.com/uole/sqlparser/dependency/querypb"
29+
"github.com/uole/sqlparser/dependency/sqltypes"
3030
)
3131

3232
// Instructions for creating new types: If a type
@@ -289,7 +289,7 @@ func (node *Select) SetLimit(limit *Limit) {
289289

290290
// Format formats the node.
291291
func (node *Select) Format(buf *TrackedBuffer) {
292-
buf.Myprintf("select %v%s%s%s%v from %v%v%v%v%v%v%s",
292+
buf.Myprintf("SELECT %v%s%s%s%v FROM %v%v%v%v%v%v%s",
293293
node.Comments, node.Cache, node.Distinct, node.Hints, node.SelectExprs,
294294
node.From, node.Where,
295295
node.GroupBy, node.Having, node.OrderBy,
@@ -478,8 +478,8 @@ type Insert struct {
478478

479479
// DDL strings.
480480
const (
481-
InsertStr = "insert"
482-
ReplaceStr = "replace"
481+
InsertStr = "INSERT"
482+
ReplaceStr = "REPLACE"
483483
)
484484

485485
// Format formats the node.
@@ -528,7 +528,7 @@ type Update struct {
528528

529529
// Format formats the node.
530530
func (node *Update) Format(buf *TrackedBuffer) {
531-
buf.Myprintf("update %v%v set %v%v%v%v",
531+
buf.Myprintf("UPDATE %v%v SET %v%v%v%v",
532532
node.Comments, node.TableExprs,
533533
node.Exprs, node.Where, node.OrderBy, node.Limit)
534534
}
@@ -562,11 +562,11 @@ type Delete struct {
562562

563563
// Format formats the node.
564564
func (node *Delete) Format(buf *TrackedBuffer) {
565-
buf.Myprintf("delete %v", node.Comments)
565+
buf.Myprintf("DELETE %v", node.Comments)
566566
if node.Targets != nil {
567567
buf.Myprintf("%v ", node.Targets)
568568
}
569-
buf.Myprintf("from %v%v%v%v%v", node.TableExprs, node.Partitions, node.Where, node.OrderBy, node.Limit)
569+
buf.Myprintf("FROM %v%v%v%v%v", node.TableExprs, node.Partitions, node.Where, node.OrderBy, node.Limit)
570570
}
571571

572572
func (node *Delete) walkSubtree(visit Visit) error {
@@ -600,9 +600,9 @@ const (
600600
// Format formats the node.
601601
func (node *Set) Format(buf *TrackedBuffer) {
602602
if node.Scope == "" {
603-
buf.Myprintf("set %v%v", node.Comments, node.Exprs)
603+
buf.Myprintf("SET %v%v", node.Comments, node.Exprs)
604604
} else {
605-
buf.Myprintf("set %v%s %v", node.Comments, node.Scope, node.Exprs)
605+
buf.Myprintf("SET %v%s %v", node.Comments, node.Scope, node.Exprs)
606606
}
607607
}
608608

@@ -634,7 +634,7 @@ func (node *DBDDL) Format(buf *TrackedBuffer) {
634634
case DropStr:
635635
exists := ""
636636
if node.IfExists {
637-
exists = " if exists"
637+
exists = " IF EXISTS"
638638
}
639639
buf.WriteString(fmt.Sprintf("%s database%s %v", node.Action, exists, node.DBName))
640640
}
@@ -1338,9 +1338,9 @@ type ShowFilter struct {
13381338
// Format formats the node.
13391339
func (node *ShowFilter) Format(buf *TrackedBuffer) {
13401340
if node.Like != "" {
1341-
buf.Myprintf("like '%s'", node.Like)
1341+
buf.Myprintf("LIKE '%s'", node.Like)
13421342
} else {
1343-
buf.Myprintf("where %v", node.Filter)
1343+
buf.Myprintf("WHERE %v", node.Filter)
13441344
}
13451345
}
13461346

@@ -1870,8 +1870,8 @@ type Where struct {
18701870

18711871
// Where.Type
18721872
const (
1873-
WhereStr = "where"
1874-
HavingStr = "having"
1873+
WhereStr = "WHERE"
1874+
HavingStr = "HAVING"
18751875
)
18761876

18771877
// NewWhere creates a WHERE or HAVING clause out
@@ -2148,8 +2148,8 @@ type RangeCond struct {
21482148

21492149
// RangeCond.Operator
21502150
const (
2151-
BetweenStr = "between"
2152-
NotBetweenStr = "not between"
2151+
BetweenStr = "BETWEEN"
2152+
NotBetweenStr = "NOT BETWEEN"
21532153
)
21542154

21552155
// Format formats the node.
@@ -2321,7 +2321,7 @@ func (node *SQLVal) Format(buf *TrackedBuffer) {
23212321
case BitVal:
23222322
buf.Myprintf("B'%s'", []byte(node.Val))
23232323
case ValArg:
2324-
buf.WriteArg(string(node.Val))
2324+
buf.WriteArg(string("?"))
23252325
default:
23262326
panic("unexpected")
23272327
}
@@ -3003,7 +3003,7 @@ type When struct {
30033003

30043004
// Format formats the node.
30053005
func (node *When) Format(buf *TrackedBuffer) {
3006-
buf.Myprintf("when %v then %v", node.Cond, node.Val)
3006+
buf.Myprintf("WHEN %v THEN %v", node.Cond, node.Val)
30073007
}
30083008

30093009
func (node *When) walkSubtree(visit Visit) error {
@@ -3022,7 +3022,7 @@ type GroupBy []Expr
30223022

30233023
// Format formats the node.
30243024
func (node GroupBy) Format(buf *TrackedBuffer) {
3025-
prefix := " group by "
3025+
prefix := " GROUP BY "
30263026
for _, n := range node {
30273027
buf.Myprintf("%s%v", prefix, n)
30283028
prefix = ", "
@@ -3043,7 +3043,7 @@ type OrderBy []*Order
30433043

30443044
// Format formats the node.
30453045
func (node OrderBy) Format(buf *TrackedBuffer) {
3046-
prefix := " order by "
3046+
prefix := " ORDER BY "
30473047
for _, n := range node {
30483048
buf.Myprintf("%s%v", prefix, n)
30493049
prefix = ", "
@@ -3067,8 +3067,8 @@ type Order struct {
30673067

30683068
// Order.Direction
30693069
const (
3070-
AscScr = "asc"
3071-
DescScr = "desc"
3070+
AscScr = "ASC"
3071+
DescScr = "DESC"
30723072
)
30733073

30743074
// Format formats the node.
@@ -3107,7 +3107,7 @@ func (node *Limit) Format(buf *TrackedBuffer) {
31073107
if node == nil {
31083108
return
31093109
}
3110-
buf.Myprintf(" limit ")
3110+
buf.Myprintf(" LIMIT ")
31113111
if node.Offset != nil {
31123112
buf.Myprintf("%v, ", node.Offset)
31133113
}
@@ -3130,7 +3130,7 @@ type Values []ValTuple
31303130

31313131
// Format formats the node.
31323132
func (node Values) Format(buf *TrackedBuffer) {
3133-
prefix := "values "
3133+
prefix := "VALUES "
31343134
for _, n := range node {
31353135
buf.Myprintf("%s%v", prefix, n)
31363136
prefix = ", "

ast_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"testing"
2525
"unsafe"
2626

27-
"github.com/xwb1989/sqlparser/dependency/sqltypes"
27+
"github.com/uole/sqlparser/dependency/sqltypes"
2828
)
2929

3030
func TestAppend(t *testing.T) {

dependency/sqltypes/bind_variables.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"reflect"
2323
"strconv"
2424

25-
"github.com/xwb1989/sqlparser/dependency/querypb"
25+
"github.com/uole/sqlparser/dependency/querypb"
2626
)
2727

2828
// NullBindVariable is a bindvar with NULL value.

dependency/sqltypes/bind_variables_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"strings"
2222
"testing"
2323

24-
"github.com/xwb1989/sqlparser/dependency/querypb"
24+
"github.com/uole/sqlparser/dependency/querypb"
2525
)
2626

2727
func TestProtoConversions(t *testing.T) {

dependency/sqltypes/plan_value.go

+24-16
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323

24-
"github.com/xwb1989/sqlparser/dependency/querypb"
24+
"github.com/uole/sqlparser/dependency/querypb"
2525
)
2626

2727
// PlanValue represents a value or a list of values for
@@ -34,28 +34,36 @@ import (
3434
// the required output is a list of rows (like in the case
3535
// of multi-value inserts), the representation is pivoted.
3636
// For example, a statement like this:
37-
// INSERT INTO t VALUES (1, 2), (3, 4)
37+
//
38+
// INSERT INTO t VALUES (1, 2), (3, 4)
39+
//
3840
// will be represented as follows:
39-
// []PlanValue{
40-
// Values: {1, 3},
41-
// Values: {2, 4},
42-
// }
41+
//
42+
// []PlanValue{
43+
// Values: {1, 3},
44+
// Values: {2, 4},
45+
// }
4346
//
4447
// For WHERE clause items that contain a combination of
4548
// equality expressions and IN clauses like this:
46-
// WHERE pk1 = 1 AND pk2 IN (2, 3, 4)
49+
//
50+
// WHERE pk1 = 1 AND pk2 IN (2, 3, 4)
51+
//
4752
// The plan values will be represented as follows:
48-
// []PlanValue{
49-
// Value: 1,
50-
// Values: {2, 3, 4},
51-
// }
53+
//
54+
// []PlanValue{
55+
// Value: 1,
56+
// Values: {2, 3, 4},
57+
// }
58+
//
5259
// When converted into rows, columns with single values
5360
// are replicated as the same for all rows:
54-
// [][]Value{
55-
// {1, 2},
56-
// {1, 3},
57-
// {1, 4},
58-
// }
61+
//
62+
// [][]Value{
63+
// {1, 2},
64+
// {1, 3},
65+
// {1, 4},
66+
// }
5967
type PlanValue struct {
6068
Key string
6169
Value Value

dependency/sqltypes/plan_value_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"strings"
2222
"testing"
2323

24-
"github.com/xwb1989/sqlparser/dependency/querypb"
24+
"github.com/uole/sqlparser/dependency/querypb"
2525
)
2626

2727
func TestPlanValueIsNull(t *testing.T) {

dependency/sqltypes/testing.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package sqltypes
1818

1919
import (
20-
querypb "github.com/xwb1989/sqlparser/dependency/querypb"
20+
querypb "github.com/uole/sqlparser/dependency/querypb"
2121
)
2222

2323
// Functions in this file should only be used for testing.

dependency/sqltypes/type.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package sqltypes
1919
import (
2020
"fmt"
2121

22-
"github.com/xwb1989/sqlparser/dependency/querypb"
22+
"github.com/uole/sqlparser/dependency/querypb"
2323
)
2424

2525
// This file provides wrappers and support

dependency/sqltypes/type_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package sqltypes
1919
import (
2020
"testing"
2121

22-
"github.com/xwb1989/sqlparser/dependency/querypb"
22+
"github.com/uole/sqlparser/dependency/querypb"
2323
)
2424

2525
func TestTypeValues(t *testing.T) {

dependency/sqltypes/value.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
"fmt"
2424
"strconv"
2525

26-
"github.com/xwb1989/sqlparser/dependency/bytes2"
27-
"github.com/xwb1989/sqlparser/dependency/hack"
26+
"github.com/uole/sqlparser/dependency/bytes2"
27+
"github.com/uole/sqlparser/dependency/hack"
2828

29-
"github.com/xwb1989/sqlparser/dependency/querypb"
29+
"github.com/uole/sqlparser/dependency/querypb"
3030
)
3131

3232
var (

dependency/sqltypes/value_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"strings"
2323
"testing"
2424

25-
"github.com/xwb1989/sqlparser/dependency/querypb"
25+
"github.com/uole/sqlparser/dependency/querypb"
2626
)
2727

2828
const (

encodable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package sqlparser
1919
import (
2020
"bytes"
2121

22-
"github.com/xwb1989/sqlparser/dependency/sqltypes"
22+
"github.com/uole/sqlparser/dependency/sqltypes"
2323
)
2424

2525
// This file contains types that are 'Encodable'.

encodable_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"bytes"
2121
"testing"
2222

23-
"github.com/xwb1989/sqlparser/dependency/sqltypes"
23+
"github.com/uole/sqlparser/dependency/sqltypes"
2424
)
2525

2626
func TestEncodable(t *testing.T) {

github_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreedto in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -45,7 +45,7 @@ func TestParsing(t *testing.T) {
4545
}
4646

4747
if _, err := Parse(test.sql); err != nil {
48-
t.Errorf("https://github.com/xwb1989/sqlparser/issues/%d:\nParse(%q) err = %s, want nil", test.id, test.sql, err)
48+
t.Errorf("https://github.com/uole/sqlparser/issues/%d:\nParse(%q) err = %s, want nil", test.id, test.sql, err)
4949
}
5050
}
5151
}

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/uole/sqlparser
2+
3+
go 1.20

go.sum

Whitespace-only changes.

normalizer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ package sqlparser
1919
import (
2020
"fmt"
2121

22-
"github.com/xwb1989/sqlparser/dependency/sqltypes"
22+
"github.com/uole/sqlparser/dependency/sqltypes"
2323

24-
"github.com/xwb1989/sqlparser/dependency/querypb"
24+
"github.com/uole/sqlparser/dependency/querypb"
2525
)
2626

2727
// Normalize changes the statement to use bind values, and

0 commit comments

Comments
 (0)