(n []parser.ITable_or_subqueryContext)
| 1046 | } |
| 1047 | |
| 1048 | func (c *cc) convertTablesOrSubquery(n []parser.ITable_or_subqueryContext) []ast.Node { |
| 1049 | var tables []ast.Node |
| 1050 | for _, ifrom := range n { |
| 1051 | from, ok := ifrom.(*parser.Table_or_subqueryContext) |
| 1052 | if !ok { |
| 1053 | continue |
| 1054 | } |
| 1055 | |
| 1056 | if from.Table_name() != nil { |
| 1057 | rel := identifier(from.Table_name().GetText()) |
| 1058 | rv := &ast.RangeVar{ |
| 1059 | Relname: &rel, |
| 1060 | Location: from.GetStart().GetStart(), |
| 1061 | } |
| 1062 | |
| 1063 | if from.Schema_name() != nil { |
| 1064 | schema := from.Schema_name().GetText() |
| 1065 | rv.Schemaname = &schema |
| 1066 | } |
| 1067 | if from.Table_alias() != nil { |
| 1068 | alias := identifier(from.Table_alias().GetText()) |
| 1069 | rv.Alias = &ast.Alias{Aliasname: &alias} |
| 1070 | } |
| 1071 | if from.Table_alias_fallback() != nil { |
| 1072 | alias := identifier(from.Table_alias_fallback().GetText()) |
| 1073 | rv.Alias = &ast.Alias{Aliasname: &alias} |
| 1074 | } |
| 1075 | |
| 1076 | tables = append(tables, rv) |
| 1077 | } else if from.Table_function_name() != nil { |
| 1078 | rel := from.Table_function_name().GetText() |
| 1079 | // Convert function arguments |
| 1080 | var args []ast.Node |
| 1081 | for _, expr := range from.AllExpr() { |
| 1082 | args = append(args, c.convert(expr)) |
| 1083 | } |
| 1084 | rf := &ast.RangeFunction{ |
| 1085 | Functions: &ast.List{ |
| 1086 | Items: []ast.Node{ |
| 1087 | &ast.FuncCall{ |
| 1088 | Func: &ast.FuncName{ |
| 1089 | Name: rel, |
| 1090 | }, |
| 1091 | Funcname: &ast.List{ |
| 1092 | Items: []ast.Node{ |
| 1093 | NewIdentifier(rel), |
| 1094 | }, |
| 1095 | }, |
| 1096 | Args: &ast.List{ |
| 1097 | Items: args, |
| 1098 | }, |
| 1099 | Location: from.GetStart().GetStart(), |
| 1100 | }, |
| 1101 | }, |
| 1102 | }, |
| 1103 | } |
| 1104 | |
| 1105 | if from.Table_alias() != nil { |
no test coverage detected