@@ -29,10 +29,14 @@ func todo(funcname string, n node) *ast.TODO {
2929}
3030
3131func identifier (id string ) string {
32+ if len (id ) >= 2 && id [0 ] == '"' && id [len (id )- 1 ] == '"' {
33+ unquoted , _ := strconv .Unquote (id )
34+ return unquoted
35+ }
3236 return strings .ToLower (id )
3337}
3438
35- func NewIdentifer (t string ) * ast.String {
39+ func NewIdentifier (t string ) * ast.String {
3640 return & ast.String {Str : identifier (t )}
3741}
3842
@@ -293,7 +297,7 @@ func (c *cc) convertFuncContext(n *parser.Expr_functionContext) ast.Node {
293297 },
294298 Funcname : & ast.List {
295299 Items : []ast.Node {
296- NewIdentifer (funcName ),
300+ NewIdentifier (funcName ),
297301 },
298302 },
299303 AggStar : n .STAR () != nil ,
@@ -317,16 +321,16 @@ func (c *cc) convertColumnNameExpr(n *parser.Expr_qualified_column_nameContext)
317321 if schema , ok := n .Schema_name ().(* parser.Schema_nameContext ); ok {
318322 schemaText := schema .GetText ()
319323 if schemaText != "" {
320- items = append (items , NewIdentifer (schemaText ))
324+ items = append (items , NewIdentifier (schemaText ))
321325 }
322326 }
323327 if table , ok := n .Table_name ().(* parser.Table_nameContext ); ok {
324328 tableName := table .GetText ()
325329 if tableName != "" {
326- items = append (items , NewIdentifer (tableName ))
330+ items = append (items , NewIdentifier (tableName ))
327331 }
328332 }
329- items = append (items , NewIdentifer (n .Column_name ().GetText ()))
333+ items = append (items , NewIdentifier (n .Column_name ().GetText ()))
330334 return & ast.ColumnRef {
331335 Fields : & ast.List {
332336 Items : items ,
@@ -384,7 +388,7 @@ func (c *cc) convertMultiSelect_stmtContext(n *parser.Select_stmtContext) ast.No
384388 tableName := identifier (cte .Table_name ().GetText ())
385389 var cteCols ast.List
386390 for _ , col := range cte .AllColumn_name () {
387- cteCols .Items = append (cteCols .Items , NewIdentifer (col .GetText ()))
391+ cteCols .Items = append (cteCols .Items , NewIdentifier (col .GetText ()))
388392 }
389393 ctes = append (ctes , & ast.CommonTableExpr {
390394 Ctename : & tableName ,
@@ -506,7 +510,7 @@ func (c *cc) getCols(core *parser.Select_coreContext) []ast.Node {
506510func (c * cc ) convertWildCardField (n * parser.Result_columnContext ) * ast.ColumnRef {
507511 items := []ast.Node {}
508512 if n .Table_name () != nil {
509- items = append (items , NewIdentifer (n .Table_name ().GetText ()))
513+ items = append (items , NewIdentifier (n .Table_name ().GetText ()))
510514 }
511515 items = append (items , & ast.A_Star {})
512516
@@ -853,7 +857,7 @@ func (c *cc) convertTablesOrSubquery(n []parser.ITable_or_subqueryContext) []ast
853857 },
854858 Funcname : & ast.List {
855859 Items : []ast.Node {
856- NewIdentifer (rel ),
860+ NewIdentifier (rel ),
857861 },
858862 },
859863 Args : & ast.List {
@@ -965,7 +969,7 @@ func (c *cc) convertCastExpr(n *parser.Expr_castContext) ast.Node {
965969 TypeName : & ast.TypeName {
966970 Name : name ,
967971 Names : & ast.List {Items : []ast.Node {
968- NewIdentifer (name ),
972+ NewIdentifier (name ),
969973 }},
970974 ArrayBounds : & ast.List {},
971975 },
0 commit comments