MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / convertCaseExpr

Method convertCaseExpr

internal/engine/clickhouse/convert.go:545–573  ·  view source on GitHub ↗
(n *chast.CaseExpr)

Source from the content-addressed store, hash-verified

543}
544
545func (c *cc) convertCaseExpr(n *chast.CaseExpr) *ast.CaseExpr {
546 ce := &ast.CaseExpr{
547 Location: n.Pos().Offset,
548 }
549
550 // Convert test expression (CASE expr WHEN ...)
551 if n.Operand != nil {
552 ce.Arg = c.convertExpr(n.Operand)
553 }
554
555 // Convert WHEN clauses
556 if len(n.Whens) > 0 {
557 ce.Args = &ast.List{}
558 for _, when := range n.Whens {
559 caseWhen := &ast.CaseWhen{
560 Expr: c.convertExpr(when.Condition),
561 Result: c.convertExpr(when.Result),
562 }
563 ce.Args.Items = append(ce.Args.Items, caseWhen)
564 }
565 }
566
567 // Convert ELSE clause
568 if n.Else != nil {
569 ce.Defresult = c.convertExpr(n.Else)
570 }
571
572 return ce
573}
574
575func (c *cc) convertCastExpr(n *chast.CastExpr) *ast.TypeCast {
576 tc := &ast.TypeCast{

Callers 1

convertExprMethod · 0.95

Calls 2

convertExprMethod · 0.95
PosMethod · 0.65

Tested by

no test coverage detected