2020-02-02 09:40:44 +03:00
|
|
|
package clause
|
|
|
|
|
|
|
|
// From from clause
|
|
|
|
type From struct {
|
|
|
|
Tables []Table
|
|
|
|
}
|
|
|
|
|
|
|
|
// Name from clause name
|
|
|
|
func (From) Name() string {
|
|
|
|
return "FROM"
|
|
|
|
}
|
|
|
|
|
2020-02-04 04:51:19 +03:00
|
|
|
var currentTable = Table{Table: CurrentTable}
|
|
|
|
|
2020-02-02 09:40:44 +03:00
|
|
|
// Build build from clause
|
|
|
|
func (from From) Build(builder Builder) {
|
2020-02-04 04:51:19 +03:00
|
|
|
if len(from.Tables) > 0 {
|
|
|
|
for idx, table := range from.Tables {
|
|
|
|
if idx > 0 {
|
|
|
|
builder.WriteByte(',')
|
|
|
|
}
|
2020-02-02 09:40:44 +03:00
|
|
|
|
2020-02-04 04:51:19 +03:00
|
|
|
builder.WriteQuoted(table)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
builder.WriteQuoted(currentTable)
|
2020-02-02 09:40:44 +03:00
|
|
|
}
|
|
|
|
}
|
2020-02-04 03:56:15 +03:00
|
|
|
|
|
|
|
// MergeExpression merge order by clauses
|
|
|
|
func (from From) MergeExpression(expr Expression) {
|
|
|
|
if v, ok := expr.(From); ok {
|
|
|
|
from.Tables = append(v.Tables, from.Tables...)
|
|
|
|
}
|
|
|
|
}
|