SQL returns the SQL representation of this WITH clause including any RECURSIVE modifier and all CTE definitions.
()
| 932 | // SQL returns the SQL representation of this WITH clause including any RECURSIVE |
| 933 | // modifier and all CTE definitions. |
| 934 | func (w *WithClause) SQL() string { |
| 935 | if w == nil { |
| 936 | return "" |
| 937 | } |
| 938 | sb := getBuilder() |
| 939 | defer putBuilder(sb) |
| 940 | sb.WriteString("WITH ") |
| 941 | if w.Recursive { |
| 942 | sb.WriteString("RECURSIVE ") |
| 943 | } |
| 944 | ctes := make([]string, len(w.CTEs)) |
| 945 | for i, cte := range w.CTEs { |
| 946 | ctes[i] = cteSQL(cte) |
| 947 | } |
| 948 | sb.WriteString(strings.Join(ctes, ", ")) |
| 949 | return sb.String() |
| 950 | } |
| 951 | |
| 952 | // SQL returns the SQL representation of this set operation as |
| 953 | // "left UNION|EXCEPT|INTERSECT [ALL] right". |