From 2b443c77233e8262b68f303318326236c69916cd Mon Sep 17 00:00:00 2001 From: loay Date: Fri, 21 Apr 2017 16:11:05 -0400 Subject: [PATCH] Add condition for postgres and oracle --- lib/sql.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/sql.js b/lib/sql.js index 42df8c9..7b52bc8 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -1185,8 +1185,13 @@ SQLConnector.prototype.buildOrderBy = function(model, order) { return ''; } var self = this; + var usedConnector = this.dataSource.connector.name; if (order === 'rand') { - return 'ORDER BY RAND()'; + if (usedConnector === 'mysql') { + return 'ORDER BY RAND()'; + } else if (usedConnector === 'postgres' || usedConnector === 'oracle') { + return 'ORDER BY RANDOM()'; + } } else { if (typeof order === 'string') { order = [order];