Skip to content

Commit

Permalink
fix: add orderBy as an option to model discoveries
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Aaqil <[email protected]>
  • Loading branch information
aaqilniz committed Dec 29, 2023
1 parent 16b9f61 commit 0051b18
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function mixinDiscovery(MySQL, mysql) {
* @param table
* @returns {String} The sql statement
*/
MySQL.prototype.buildQueryColumns = function(schema, table) {
MySQL.prototype.buildQueryColumns = function(schema, table, options) {
let sql = null;
if (schema) {
sql = paginateSQL('SELECT table_schema AS "owner",' +
Expand Down Expand Up @@ -186,7 +186,9 @@ function mixinDiscovery(MySQL, mysql) {
(table ? ' WHERE table_name=' + mysql.escape(table) : ''),
'table_name, ordinal_position', {});
}
sql += ' ORDER BY ordinal_position';
if (options.orderBy) {
sql += ' ORDER BY ' + options.orderBy;
}
return sql;
};

Expand Down

0 comments on commit 0051b18

Please sign in to comment.