1 Star 0 Fork 1

go-genie / sqlx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
addition_combination.go 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
lijun 提交于 2024-02-19 15:56 . init: initialization project
package builder
import (
"context"
)
type CombinationAddition struct {
}
func (CombinationAddition) AdditionType() AdditionType {
return AdditionCombination
}
func Union() *combination {
return &combination{
operator: "UNION",
}
}
func Intersect() *combination {
return &combination{
operator: "INTERSECT",
}
}
func Expect() *combination {
return &combination{
operator: "EXCEPT",
}
}
var _ Addition = (*combination)(nil)
type combination struct {
CombinationAddition
operator string // UNION | INTERSECT | EXCEPT
method string // ALL | DISTINCT
stmtSelect SelectStatement
}
func (c *combination) IsNil() bool {
return c == nil || IsNilExpr(c.stmtSelect)
}
func (c combination) All(stmtSelect SelectStatement) *combination {
c.method = "ALL"
c.stmtSelect = stmtSelect
return &c
}
func (c combination) Distinct(stmtSelect SelectStatement) *combination {
c.method = "DISTINCT"
c.stmtSelect = stmtSelect
return &c
}
func (c *combination) Ex(ctx context.Context) *Ex {
e := Expr("")
e.Grow(1)
e.WriteQuery(c.operator)
e.WriteQueryByte(' ')
if c.method != "" {
e.WriteQuery(c.method)
e.WriteQueryByte(' ')
}
e.WriteExpr(c.stmtSelect)
return e.Ex(ctx)
}
1
https://gitee.com/go-genie/sqlx.git
git@gitee.com:go-genie/sqlx.git
go-genie
sqlx
sqlx
v1.0.3

搜索帮助