Skip to content

Commit 0051b18

Browse files
committed
fix: add orderBy as an option to model discoveries
Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
1 parent 16b9f61 commit 0051b18

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/discovery.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function mixinDiscovery(MySQL, mysql) {
154154
* @param table
155155
* @returns {String} The sql statement
156156
*/
157-
MySQL.prototype.buildQueryColumns = function(schema, table) {
157+
MySQL.prototype.buildQueryColumns = function(schema, table, options) {
158158
let sql = null;
159159
if (schema) {
160160
sql = paginateSQL('SELECT table_schema AS "owner",' +
@@ -186,7 +186,9 @@ function mixinDiscovery(MySQL, mysql) {
186186
(table ? ' WHERE table_name=' + mysql.escape(table) : ''),
187187
'table_name, ordinal_position', {});
188188
}
189-
sql += ' ORDER BY ordinal_position';
189+
if (options.orderBy) {
190+
sql += ' ORDER BY ' + options.orderBy;
191+
}
190192
return sql;
191193
};
192194

0 commit comments

Comments
 (0)