mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/sql: improve support for subqueries (#3274)
This commit is contained in:
@@ -2367,7 +2367,25 @@ func (s *Selector) Table() *SelectTable {
|
||||
if len(s.from) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.from[0].(*SelectTable)
|
||||
return selectTable(s.from[0])
|
||||
}
|
||||
|
||||
// selectTable returns a *SelectTable from the given TableView.
|
||||
func selectTable(tb TableView) *SelectTable {
|
||||
if tb == nil {
|
||||
return nil
|
||||
}
|
||||
switch view := tb.(type) {
|
||||
case *SelectTable:
|
||||
return view
|
||||
case *Selector:
|
||||
if len(view.from) == 0 {
|
||||
return nil
|
||||
}
|
||||
return selectTable(view.from[0])
|
||||
default:
|
||||
panic(fmt.Sprintf("unhandled TableView type %T", tb))
|
||||
}
|
||||
}
|
||||
|
||||
// TableName returns the name of the selected table or alias of selector.
|
||||
|
||||
Reference in New Issue
Block a user