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

Function orderBySQL

pkg/formatter/render.go:1228–1245  ·  view source on GitHub ↗

orderBySQL renders ORDER BY expressions.

(orders []ast.OrderByExpression)

Source from the content-addressed store, hash-verified

1226
1227// orderBySQL renders ORDER BY expressions.
1228func orderBySQL(orders []ast.OrderByExpression) string {
1229 parts := make([]string, len(orders))
1230 for i, o := range orders {
1231 s := exprSQL(o.Expression)
1232 if !o.Ascending {
1233 s += " DESC"
1234 }
1235 if o.NullsFirst != nil {
1236 if *o.NullsFirst {
1237 s += " NULLS FIRST"
1238 } else {
1239 s += " NULLS LAST"
1240 }
1241 }
1242 parts[i] = s
1243 }
1244 return strings.Join(parts, ", ")
1245}
1246
1247// tableRefSQL renders a TableReference. The formatter is threaded through
1248// so PIVOT/UNPIVOT/FOR/IN/AS/LATERAL keywords honor the caller's case policy.

Callers 2

renderSelectFunction · 0.70
windowSpecSQLFunction · 0.70

Calls 1

exprSQLFunction · 0.70

Tested by

no test coverage detected