Skip to content

Commit

Permalink
fix: add option
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Aaqil <[email protected]>
  • Loading branch information
aaqilniz committed Jan 21, 2024
1 parent 7360459 commit 0d5c807
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 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, options) {
MySQL.prototype.buildQueryColumns = function(schema, table, options = {}) {
let sql = null;
if (schema) {
sql = paginateSQL('SELECT table_schema AS "owner",' +
Expand Down
24 changes: 24 additions & 0 deletions test/mysql.discover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,30 @@ describe('Discover model properties', function() {
'EXTRAS',
'FIRE_MODES',
];
db.discoverModelProperties('PRODUCT', {orderBy: 'ordinal_position'}, function(err, models) {
if (err) {
console.error(err);
done(err);
} else {
models.forEach(function(m) { productProperties.push(m.columnName); });
productProperties.forEach((prop, index) => {
assert(productPropertiesInOrdinalOrder[index] === prop);
});
done(null, models);
}
});
});
it('should return an array of columns for product in default (alphabatical) order', function(done) {
const productProperties = [];
const productPropertiesInOrdinalOrder = [
'AUDIBLE_RANGE',
'EFFECTIVE_RANGE',
'EXTRAS',
'FIRE_MODES',
'ID',
'NAME',
'ROUNDS',
];
db.discoverModelProperties('PRODUCT', function(err, models) {
if (err) {
console.error(err);
Expand Down

0 comments on commit 0d5c807

Please sign in to comment.