@@ -5,10 +5,10 @@ import (
55 "log"
66 "strings"
77
8- pcast "github.com/pingcap/parser/ast"
9- "github.com/pingcap/parser/opcode"
10- driver "github.com/pingcap/parser/test_driver"
11- "github.com/pingcap/parser/types"
8+ pcast "github.com/pingcap/tidb/ parser/ast"
9+ "github.com/pingcap/tidb/ parser/opcode"
10+ driver "github.com/pingcap/tidb/ parser/test_driver"
11+ "github.com/pingcap/tidb/ parser/types"
1212
1313 "github.com/kyleconroy/sqlc/internal/debug"
1414 "github.com/kyleconroy/sqlc/internal/sql/ast"
@@ -45,11 +45,11 @@ func (c *cc) convertAlterTableStmt(n *pcast.AlterTableStmt) ast.Node {
4545 name := def .Name .String ()
4646 columnDef := ast.ColumnDef {
4747 Colname : def .Name .String (),
48- TypeName : & ast.TypeName {Name : types .TypeStr (def .Tp .Tp )},
48+ TypeName : & ast.TypeName {Name : types .TypeStr (def .Tp .GetType () )},
4949 IsNotNull : isNotNull (def ),
5050 }
51- if def .Tp .Flen >= 0 {
52- length := def .Tp .Flen
51+ if def .Tp .GetFlen () >= 0 {
52+ length := def .Tp .GetFlen ()
5353 columnDef .Length = & length
5454 }
5555 alt .Cmds .Items = append (alt .Cmds .Items , & ast.AlterTableCmd {
@@ -78,11 +78,11 @@ func (c *cc) convertAlterTableStmt(n *pcast.AlterTableStmt) ast.Node {
7878 name := def .Name .String ()
7979 columnDef := ast.ColumnDef {
8080 Colname : def .Name .String (),
81- TypeName : & ast.TypeName {Name : types .TypeStr (def .Tp .Tp )},
81+ TypeName : & ast.TypeName {Name : types .TypeStr (def .Tp .GetType () )},
8282 IsNotNull : isNotNull (def ),
8383 }
84- if def .Tp .Flen >= 0 {
85- length := def .Tp .Flen
84+ if def .Tp .GetFlen () >= 0 {
85+ length := def .Tp .GetFlen ()
8686 columnDef .Length = & length
8787 }
8888 alt .Cmds .Items = append (alt .Cmds .Items , & ast.AlterTableCmd {
@@ -97,11 +97,11 @@ func (c *cc) convertAlterTableStmt(n *pcast.AlterTableStmt) ast.Node {
9797 name := def .Name .String ()
9898 columnDef := ast.ColumnDef {
9999 Colname : def .Name .String (),
100- TypeName : & ast.TypeName {Name : types .TypeStr (def .Tp .Tp )},
100+ TypeName : & ast.TypeName {Name : types .TypeStr (def .Tp .GetType () )},
101101 IsNotNull : isNotNull (def ),
102102 }
103- if def .Tp .Flen >= 0 {
104- length := def .Tp .Flen
103+ if def .Tp .GetFlen () >= 0 {
104+ length := def .Tp .GetFlen ()
105105 columnDef .Length = & length
106106 }
107107 alt .Cmds .Items = append (alt .Cmds .Items , & ast.AlterTableCmd {
@@ -247,11 +247,11 @@ func (c *cc) convertCreateTableStmt(n *pcast.CreateTableStmt) ast.Node {
247247 }
248248 for _ , def := range n .Cols {
249249 var vals * ast.List
250- if len (def .Tp .Elems ) > 0 {
250+ if len (def .Tp .GetElems () ) > 0 {
251251 vals = & ast.List {}
252- for i := range def .Tp .Elems {
252+ for i := range def .Tp .GetElems () {
253253 vals .Items = append (vals .Items , & ast.String {
254- Str : def .Tp .Elems [i ],
254+ Str : def .Tp .GetElems () [i ],
255255 })
256256 }
257257 }
@@ -266,13 +266,13 @@ func (c *cc) convertCreateTableStmt(n *pcast.CreateTableStmt) ast.Node {
266266 }
267267 columnDef := ast.ColumnDef {
268268 Colname : def .Name .String (),
269- TypeName : & ast.TypeName {Name : types .TypeStr (def .Tp .Tp )},
269+ TypeName : & ast.TypeName {Name : types .TypeStr (def .Tp .GetType () )},
270270 IsNotNull : isNotNull (def ),
271271 Comment : comment ,
272272 Vals : vals ,
273273 }
274- if def .Tp .Flen >= 0 {
275- length := def .Tp .Flen
274+ if def .Tp .GetFlen () >= 0 {
275+ length := def .Tp .GetFlen ()
276276 columnDef .Length = & length
277277 }
278278 create .Cols = append (create .Cols , & columnDef )
@@ -763,7 +763,7 @@ func (c *cc) convertCreateBindingStmt(n *pcast.CreateBindingStmt) ast.Node {
763763
764764func (c * cc ) convertCreateDatabaseStmt (n * pcast.CreateDatabaseStmt ) ast.Node {
765765 return & ast.CreateSchemaStmt {
766- Name : & n .Name ,
766+ Name : & n .Name . O ,
767767 IfNotExists : n .IfNotExists ,
768768 }
769769}
@@ -819,7 +819,7 @@ func (c *cc) convertDropDatabaseStmt(n *pcast.DropDatabaseStmt) ast.Node {
819819 return & ast.DropSchemaStmt {
820820 MissingOk : ! n .IfExists ,
821821 Schemas : []* ast.String {
822- NewIdentifier (n .Name ),
822+ NewIdentifier (n .Name . O ),
823823 },
824824 }
825825}
@@ -1076,10 +1076,6 @@ func (c *cc) convertPatternRegexpExpr(n *pcast.PatternRegexpExpr) ast.Node {
10761076 return todo (n )
10771077}
10781078
1079- func (c * cc ) convertPlacementSpec (n * pcast.PlacementSpec ) ast.Node {
1080- return todo (n )
1081- }
1082-
10831079func (c * cc ) convertPositionExpr (n * pcast.PositionExpr ) ast.Node {
10841080 return todo (n )
10851081}
@@ -1626,9 +1622,6 @@ func (c *cc) convert(node pcast.Node) ast.Node {
16261622 case * pcast.PatternRegexpExpr :
16271623 return c .convertPatternRegexpExpr (n )
16281624
1629- case * pcast.PlacementSpec :
1630- return c .convertPlacementSpec (n )
1631-
16321625 case * pcast.PositionExpr :
16331626 return c .convertPositionExpr (n )
16341627
0 commit comments