MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / SQL

Method SQL

pkg/sql/ast/sql.go:336–373  ·  view source on GitHub ↗

SQL returns the SQL representation of this function call including arguments, optional DISTINCT modifier, ORDER BY clause (for aggregates like STRING_AGG), WITHIN GROUP (for ordered-set aggregates), FILTER (WHERE ...) clause, and OVER (...) window specification.

()

Source from the content-addressed store, hash-verified

334// WITHIN GROUP (for ordered-set aggregates), FILTER (WHERE ...) clause, and
335// OVER (...) window specification.
336func (f *FunctionCall) SQL() string {
337 if f == nil {
338 return ""
339 }
340 sb := getBuilder()
341 defer putBuilder(sb)
342 sb.WriteString(f.Name)
343 sb.WriteString("(")
344 if f.Distinct {
345 sb.WriteString("DISTINCT ")
346 }
347 args := make([]string, len(f.Arguments))
348 for i, arg := range f.Arguments {
349 args[i] = exprSQL(arg)
350 }
351 sb.WriteString(strings.Join(args, ", "))
352 if len(f.OrderBy) > 0 {
353 sb.WriteString(" ORDER BY ")
354 sb.WriteString(orderBySQL(f.OrderBy))
355 }
356 sb.WriteString(")")
357 if len(f.WithinGroup) > 0 {
358 sb.WriteString(" WITHIN GROUP (ORDER BY ")
359 sb.WriteString(orderBySQL(f.WithinGroup))
360 sb.WriteString(")")
361 }
362 if f.Filter != nil {
363 sb.WriteString(" FILTER (WHERE ")
364 sb.WriteString(exprSQL(f.Filter))
365 sb.WriteString(")")
366 }
367 if f.Over != nil {
368 sb.WriteString(" OVER (")
369 sb.WriteString(windowSpecSQL(f.Over))
370 sb.WriteString(")")
371 }
372 return sb.String()
373}
374
375// SQL returns "EXTRACT(field FROM source)" as a SQL string.
376func (e *ExtractExpression) SQL() string {

Callers

nothing calls this directly

Calls 6

getBuilderFunction · 0.85
putBuilderFunction · 0.85
exprSQLFunction · 0.70
orderBySQLFunction · 0.70
windowSpecSQLFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected