@@ -161,6 +161,19 @@ namespace hsql {
161161 }
162162 }
163163
164+ void printOrderBy (const std::vector<OrderDescription*>* expr, uintmax_t numIndent) {
165+ if (!expr) return ;
166+ for (const auto & order_description : *expr) {
167+ printExpression (order_description->expr , numIndent);
168+ if (order_description->type == kOrderAsc ) {
169+ inprint (" ascending" , numIndent);
170+ }
171+ else {
172+ inprint (" descending" , numIndent);
173+ }
174+ }
175+ }
176+
164177 void printSelectStatementInfo (const SelectStatement* stmt, uintmax_t numIndent) {
165178 inprint (" SelectStatement" , numIndent);
166179 inprint (" Fields:" , numIndent + 1 );
@@ -203,9 +216,7 @@ namespace hsql {
203216
204217 if (setOperation->resultOrder != nullptr ) {
205218 inprint (" SetResultOrderBy:" , numIndent + 1 );
206- printExpression (setOperation->resultOrder ->at (0 )->expr , numIndent + 2 );
207- if (setOperation->resultOrder ->at (0 )->type == kOrderAsc ) inprint (" ascending" , numIndent + 2 );
208- else inprint (" descending" , numIndent + 2 );
219+ printOrderBy (setOperation->resultOrder , numIndent + 2 );
209220 }
210221
211222 if (setOperation->resultLimit != nullptr ) {
@@ -224,15 +235,7 @@ namespace hsql {
224235
225236 if (stmt->order != nullptr ) {
226237 inprint (" OrderBy:" , numIndent + 1 );
227- for (size_t idx = 0 ; idx < stmt->order ->size (); idx++) {
228- printExpression (stmt->order ->at (idx)->expr , numIndent + 2 );
229- if (stmt->order ->at (idx)->type == kOrderAsc ) {
230- inprint (" ascending" , numIndent + 2 );
231- }
232- else {
233- inprint (" descending" , numIndent + 2 );
234- }
235- }
238+ printOrderBy (stmt->order , numIndent + 2 );
236239 }
237240
238241 if (stmt->limit != nullptr && stmt->limit ->limit != nullptr ) {
0 commit comments