(depth int, w expr.DialectWriter)
| 1150 | return w.String() |
| 1151 | } |
| 1152 | func (m *SqlSelect) writeDialectDepth(depth int, w expr.DialectWriter) { |
| 1153 | |
| 1154 | io.WriteString(w, "SELECT ") |
| 1155 | if m.Distinct { |
| 1156 | io.WriteString(w, "DISTINCT ") |
| 1157 | } |
| 1158 | m.Columns.WriteDialect(w) |
| 1159 | if m.Into != nil { |
| 1160 | io.WriteString(w, " INTO ") |
| 1161 | w.WriteIdentity(m.Into.Table) |
| 1162 | } |
| 1163 | if m.From != nil { |
| 1164 | io.WriteString(w, " FROM") |
| 1165 | for i, from := range m.From { |
| 1166 | if i == 0 { |
| 1167 | io.WriteString(w, " ") |
| 1168 | } else { |
| 1169 | if from.SubQuery != nil { |
| 1170 | io.WriteString(w, "\n") |
| 1171 | io.WriteString(w, strings.Repeat("\t", depth+1)) |
| 1172 | } else { |
| 1173 | io.WriteString(w, "\n") |
| 1174 | io.WriteString(w, strings.Repeat("\t", depth+1)) |
| 1175 | } |
| 1176 | } |
| 1177 | from.writeDialectDepth(depth+1, w) |
| 1178 | } |
| 1179 | } |
| 1180 | if m.Where != nil { |
| 1181 | io.WriteString(w, " WHERE ") |
| 1182 | m.Where.writeDialectDepth(depth, w) |
| 1183 | } |
| 1184 | if len(m.GroupBy) > 0 { |
| 1185 | io.WriteString(w, " GROUP BY ") |
| 1186 | m.GroupBy.WriteDialect(w) |
| 1187 | } |
| 1188 | if m.Having != nil { |
| 1189 | io.WriteString(w, " HAVING ") |
| 1190 | m.Having.WriteDialect(w) |
| 1191 | } |
| 1192 | if len(m.OrderBy) > 0 { |
| 1193 | io.WriteString(w, " ORDER BY ") |
| 1194 | m.OrderBy.WriteDialect(w) |
| 1195 | } |
| 1196 | if m.Limit > 0 { |
| 1197 | io.WriteString(w, fmt.Sprintf(" LIMIT %d", m.Limit)) |
| 1198 | } |
| 1199 | if m.Offset > 0 { |
| 1200 | io.WriteString(w, fmt.Sprintf(" OFFSET %d", m.Offset)) |
| 1201 | } |
| 1202 | } |
| 1203 | func (m *SqlSelect) FingerPrintID() int64 { |
| 1204 | if m.fingerprintid == 0 { |
| 1205 | h := fnv.New64() |
no test coverage detected