You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
630 B
38 lines
630 B
3 years ago
|
package clause
|
||
|
|
||
|
// From from clause
|
||
|
type From struct {
|
||
|
Tables []Table
|
||
|
Joins []Join
|
||
|
}
|
||
|
|
||
|
// Name from clause name
|
||
|
func (from From) Name() string {
|
||
|
return "FROM"
|
||
|
}
|
||
|
|
||
|
// Build build from clause
|
||
|
func (from From) Build(builder Builder) {
|
||
|
if len(from.Tables) > 0 {
|
||
|
for idx, table := range from.Tables {
|
||
|
if idx > 0 {
|
||
|
builder.WriteByte(',')
|
||
|
}
|
||
|
|
||
|
builder.WriteQuoted(table)
|
||
|
}
|
||
|
} else {
|
||
|
builder.WriteQuoted(currentTable)
|
||
|
}
|
||
|
|
||
|
for _, join := range from.Joins {
|
||
|
builder.WriteByte(' ')
|
||
|
join.Build(builder)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// MergeClause merge from clause
|
||
|
func (from From) MergeClause(clause *Clause) {
|
||
|
clause.Expression = from
|
||
|
}
|