(databaseName string, expr ast.TableExpr, out map[string]*TableReference)
| 248 | } |
| 249 | |
| 250 | func collectSingleTablesFromExpr(databaseName string, expr ast.TableExpr, out map[string]*TableReference) { |
| 251 | switch e := expr.(type) { |
| 252 | case *ast.TableRef: |
| 253 | db := e.Schema |
| 254 | if db == "" { |
| 255 | db = databaseName |
| 256 | } |
| 257 | ref := &TableReference{ |
| 258 | Database: db, |
| 259 | Table: e.Name, |
| 260 | Alias: e.Alias, |
| 261 | } |
| 262 | key := e.Name |
| 263 | if e.Alias != "" { |
| 264 | key = e.Alias |
| 265 | } |
| 266 | out[key] = ref |
| 267 | case *ast.JoinClause: |
| 268 | if e.Left != nil { |
| 269 | collectSingleTablesFromExpr(databaseName, e.Left, out) |
| 270 | } |
| 271 | if e.Right != nil { |
| 272 | collectSingleTablesFromExpr(databaseName, e.Right, out) |
| 273 | } |
| 274 | default: |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | // collectCTENames extracts CTE names from the SQL text before the statement Loc. |
| 279 | // MySQL's UPDATE/DELETE CTEs are not in the omni AST, so we parse the prefix. |
no outgoing calls
no test coverage detected