Skip to content

Commit 656af22

Browse files
authored
update pg_query_go to v4 (#31)
1 parent 443693f commit 656af22

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/houqp/gtest v1.0.0
77
github.com/logrusorgru/aurora v2.0.3+incompatible
88
github.com/pelletier/go-toml v1.9.5
9-
github.com/pganalyze/pg_query_go/v2 v2.2.0
9+
github.com/pganalyze/pg_query_go/v4 v4.2.0
1010
github.com/sirupsen/logrus v1.9.0
1111
github.com/spf13/cobra v1.6.1
1212
github.com/stretchr/testify v1.8.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczG
2929
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
3030
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
3131
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
32-
github.com/pganalyze/pg_query_go/v2 v2.2.0 h1:OW+reH+ZY7jdEuPyuLGlf1m7dLbE+fDudKXhLs0Ttpk=
33-
github.com/pganalyze/pg_query_go/v2 v2.2.0/go.mod h1:XAxmVqz1tEGqizcQ3YSdN90vCOHBWjJi8URL1er5+cA=
32+
github.com/pganalyze/pg_query_go/v4 v4.2.0 h1:67hSBZXYfABNYisEu/Xfu6R2gupnQwaoRhQicy0HSnQ=
33+
github.com/pganalyze/pg_query_go/v4 v4.2.0/go.mod h1:aEkDNOXNM5j0YGzaAapwJ7LB3dLNj+bvbWcLv1hOVqA=
3434
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3535
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3636
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

pkg/schema/postgres.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"os"
55
"strings"
66

7-
pg_query "github.com/pganalyze/pg_query_go/v2"
7+
pg_query "github.com/pganalyze/pg_query_go/v4"
88
)
99

1010
func (s *Db) LoadPostgres(schemaPath string) error {
@@ -53,7 +53,7 @@ func parsePostgresSchema(schemaInput string) (map[string]Table, error) {
5353
continue
5454
}
5555
tStr := typNode.GetString_()
56-
typeParts = append(typeParts, tStr.Str)
56+
typeParts = append(typeParts, tStr.Sval)
5757
}
5858

5959
colName := colDef.Colname
@@ -136,5 +136,5 @@ func GetResTargetColumn(resTarget *pg_query.ResTarget) (col Column, ok bool) {
136136
return
137137
}
138138

139-
return Column{Name: colField.GetString_().GetStr()}, true
139+
return Column{Name: colField.GetString_().Sval}, true
140140
}

pkg/vet/vet.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"reflect"
88

9-
pg_query "github.com/pganalyze/pg_query_go/v2"
9+
pg_query "github.com/pganalyze/pg_query_go/v4"
1010

1111
"github.com/houqp/sqlvet/pkg/schema"
1212
)
@@ -130,7 +130,7 @@ func columnRefToColumnUsed(colRef *pg_query.ColumnRef) *ColumnUsed {
130130
var colField *pg_query.Node
131131
if len(colRef.Fields) > 1 {
132132
// in the form of SELECT table.column FROM table
133-
cu.Table = colRef.Fields[0].GetString_().Str
133+
cu.Table = colRef.Fields[0].GetString_().Sval
134134
// fmt.Printf("table: %s\n", cu.Table)
135135
colField = colRef.Fields[1]
136136
} else {
@@ -140,7 +140,7 @@ func columnRefToColumnUsed(colRef *pg_query.ColumnRef) *ColumnUsed {
140140

141141
switch {
142142
case colField.GetString_() != nil:
143-
cu.Column = colField.GetString_().GetStr()
143+
cu.Column = colField.GetString_().Sval
144144
case colField.GetAStar() != nil:
145145
// SELECT *
146146
return nil

0 commit comments

Comments
 (0)