MCPcopy Create free account
hub / github.com/bytebase/bytebase / findPhysicalTableForAliasInNode

Function findPhysicalTableForAliasInNode

backend/plugin/parser/tsql/backup.go:290–318  ·  view source on GitHub ↗
(node ast.Node, table *TableReference)

Source from the content-addressed store, hash-verified

288}
289
290func 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
320func 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 {

Callers 1

Calls 1

Tested by

no test coverage detected