Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
37 lines
792 B
Go
37 lines
792 B
Go
package ast
|
|
|
|
import "github.com/sqlc-dev/sqlc/internal/sql/format"
|
|
|
|
type CaseExpr struct {
|
|
Tag NodeTag[CaseExpr] `json:"tag"`
|
|
|
|
Xpr Node `json:"xpr,omitempty"`
|
|
Casetype Oid `json:"casetype"`
|
|
Casecollid Oid `json:"casecollid"`
|
|
Arg Node `json:"arg,omitempty"`
|
|
Args *List `json:"args,omitempty"`
|
|
Defresult Node `json:"defresult,omitempty"`
|
|
Location int `json:"location"`
|
|
}
|
|
|
|
func (n *CaseExpr) Pos() int {
|
|
return n.Location
|
|
}
|
|
|
|
func (n *CaseExpr) Format(buf *TrackedBuffer, d format.Dialect) {
|
|
if n == nil {
|
|
return
|
|
}
|
|
buf.WriteString("CASE ")
|
|
if set(n.Arg) {
|
|
buf.astFormat(n.Arg, d)
|
|
buf.WriteString(" ")
|
|
}
|
|
buf.join(n.Args, d, " ")
|
|
if set(n.Defresult) {
|
|
buf.WriteString(" ELSE ")
|
|
buf.astFormat(n.Defresult, d)
|
|
}
|
|
buf.WriteString(" END")
|
|
}
|