Lateral - initial commit.

This commit is contained in:
go-jet 2020-10-16 13:26:53 +02:00
parent 1146afe343
commit 0cba1f6401
4 changed files with 73 additions and 2 deletions

View file

@ -13,8 +13,8 @@ type selectTableImpl struct {
}
// NewSelectTable func
func NewSelectTable(selectStmt SerializerStatement, alias string) SelectTable {
selectTable := &selectTableImpl{selectStmt: selectStmt, alias: alias}
func NewSelectTable(selectStmt SerializerStatement, alias string) selectTableImpl {
selectTable := selectTableImpl{selectStmt: selectStmt, alias: alias}
return selectTable
}
@ -38,3 +38,21 @@ func (s selectTableImpl) serialize(statement StatementType, out *SQLBuilder, opt
out.WriteString("AS")
out.WriteIdentifier(s.alias)
}
// --------------------------------------
type lateralImpl struct {
selectTableImpl
}
func NewLateral(selectStmt SerializerStatement, alias string) SelectTable {
return lateralImpl{selectTableImpl: NewSelectTable(selectStmt, alias)}
}
func (s lateralImpl) serialize(statement StatementType, out *SQLBuilder, options ...SerializeOption) {
out.WriteString("LATERAL")
s.selectStmt.serialize(statement, out)
out.WriteString("AS")
out.WriteIdentifier(s.alias)
}