(node ast.Node, table *TableReference)
| 288 | } |
| 289 | |
| 290 | func findPhysicalTableForAliasInNode(node ast.Node, table *TableReference) *TableReference { |
| 291 | switch n := node.(type) { |
| 292 | case *ast.TableRef: |
| 293 | if n.Alias != "" && n.Alias == table.Table { |
| 294 | ref, err := tableReferenceFromTableExpr(n, table.Database, table.Schema) |
| 295 | if err != nil { |
| 296 | return nil |
| 297 | } |
| 298 | ref.Alias = n.Alias |
| 299 | return ref |
| 300 | } |
| 301 | case *ast.AliasedTableRef: |
| 302 | if ref, ok := n.Table.(*ast.TableRef); ok && n.Alias == table.Table { |
| 303 | result, err := tableReferenceFromTableExpr(ref, table.Database, table.Schema) |
| 304 | if err != nil { |
| 305 | return nil |
| 306 | } |
| 307 | result.Alias = n.Alias |
| 308 | return result |
| 309 | } |
| 310 | case *ast.JoinClause: |
| 311 | if result := findPhysicalTableForAliasInNode(n.Left, table); result != nil { |
| 312 | return result |
| 313 | } |
| 314 | return findPhysicalTableForAliasInNode(n.Right, table) |
| 315 | default: |
| 316 | } |
| 317 | return nil |
| 318 | } |
| 319 | |
| 320 | func dmlFromSource(source string, relation ast.TableExpr, fromClause *ast.List, stmtLoc ast.Loc, where ast.ExprNode, option *ast.List) (string, int) { |
| 321 | if fromClause != nil && len(fromClause.Items) > 0 { |
no test coverage detected