MCPcopy
hub / github.com/sqlc-dev/sqlc / convertFuncContext

Method convertFuncContext

internal/engine/sqlite/convert.go:271–312  ·  view source on GitHub ↗
(n *parser.Expr_functionContext)

Source from the content-addressed store, hash-verified

269}
270
271func (c *cc) convertFuncContext(n *parser.Expr_functionContext) ast.Node {
272 if name, ok := n.Qualified_function_name().(*parser.Qualified_function_nameContext); ok {
273 funcName := strings.ToLower(name.Function_name().GetText())
274
275 schema := ""
276 if name.Schema_name() != nil {
277 schema = name.Schema_name().GetText()
278 }
279
280 var argNodes []ast.Node
281 for _, exp := range n.AllExpr() {
282 argNodes = append(argNodes, c.convert(exp))
283 }
284 args := &ast.List{Items: argNodes}
285
286 if funcName == "coalesce" {
287 return &ast.CoalesceExpr{
288 Args: args,
289 Location: name.GetStart().GetStart(),
290 }
291 } else {
292 return &ast.FuncCall{
293 Func: &ast.FuncName{
294 Schema: schema,
295 Name: funcName,
296 },
297 Funcname: &ast.List{
298 Items: []ast.Node{
299 NewIdentifier(funcName),
300 },
301 },
302 AggStar: n.STAR() != nil,
303 Args: args,
304 AggOrder: &ast.List{},
305 AggDistinct: n.DISTINCT_() != nil,
306 Location: name.GetStart().GetStart(),
307 }
308 }
309 }
310
311 return todo("convertFuncContext", n)
312}
313
314func (c *cc) convertExprContext(n *parser.ExprContext) ast.Node {
315 return &ast.Expr{}

Callers 1

convertMethod · 0.95

Calls 11

convertMethod · 0.95
GetTextMethod · 0.80
GetStartMethod · 0.80
NewIdentifierFunction · 0.70
todoFunction · 0.70
Function_nameMethod · 0.65
Schema_nameMethod · 0.65
AllExprMethod · 0.65
STARMethod · 0.65
DISTINCT_Method · 0.65

Tested by

no test coverage detected