(n Update_stmt)
| 1135 | } |
| 1136 | |
| 1137 | func (c *cc) convertUpdate_stmtContext(n Update_stmt) ast.Node { |
| 1138 | if n == nil { |
| 1139 | return nil |
| 1140 | } |
| 1141 | |
| 1142 | relations := &ast.List{} |
| 1143 | tableName := identifier(n.Qualified_table_name().GetText()) |
| 1144 | rel := ast.RangeVar{ |
| 1145 | Relname: &tableName, |
| 1146 | Location: n.GetStart().GetStart(), |
| 1147 | } |
| 1148 | relations.Items = append(relations.Items, &rel) |
| 1149 | |
| 1150 | list := &ast.List{} |
| 1151 | for i, col := range n.AllColumn_name() { |
| 1152 | colName := identifier(col.GetText()) |
| 1153 | target := &ast.ResTarget{ |
| 1154 | Name: &colName, |
| 1155 | Val: c.convert(n.Expr(i)), |
| 1156 | } |
| 1157 | list.Items = append(list.Items, target) |
| 1158 | } |
| 1159 | |
| 1160 | var where ast.Node = nil |
| 1161 | if n.WHERE_() != nil { |
| 1162 | where = c.convert(n.Expr(len(n.AllExpr()) - 1)) |
| 1163 | } |
| 1164 | |
| 1165 | stmt := &ast.UpdateStmt{ |
| 1166 | Relations: relations, |
| 1167 | TargetList: list, |
| 1168 | WhereClause: where, |
| 1169 | FromClause: &ast.List{}, |
| 1170 | WithClause: nil, // TODO: support with clause |
| 1171 | } |
| 1172 | if n, ok := n.(interface { |
| 1173 | Returning_clause() parser.IReturning_clauseContext |
| 1174 | }); ok { |
| 1175 | stmt.ReturningList = c.convertReturning_caluseContext(n.Returning_clause()) |
| 1176 | } else { |
| 1177 | stmt.ReturningList = c.convertReturning_caluseContext(nil) |
| 1178 | } |
| 1179 | if n, ok := n.(interface { |
| 1180 | Limit_stmt() parser.ILimit_stmtContext |
| 1181 | }); ok { |
| 1182 | limitCount, _ := c.convertLimit_stmtContext(n.Limit_stmt()) |
| 1183 | stmt.LimitCount = limitCount |
| 1184 | } |
| 1185 | return stmt |
| 1186 | } |
| 1187 | |
| 1188 | func (c *cc) convertBetweenExpr(n *parser.Expr_betweenContext) ast.Node { |
| 1189 | return &ast.BetweenExpr{ |
no test coverage detected