44// License text available at https://opensource.org/licenses/MIT
55
66'use strict' ;
7- var g = require ( 'strong-globalize' ) ( ) ;
7+ const g = require ( 'strong-globalize' ) ( ) ;
88
99module . exports = mixinDiscovery ;
1010
@@ -13,20 +13,20 @@ module.exports = mixinDiscovery;
1313 * @param {Object } mysql mysql driver
1414 */
1515function mixinDiscovery ( MySQL , mysql ) {
16- var async = require ( 'async' ) ;
16+ const async = require ( 'async' ) ;
1717
1818 function paginateSQL ( sql , orderBy , options ) {
1919 options = options || { } ;
20- var limitClause = '' ;
20+ let limitClause = '' ;
2121 if ( options . offset || options . skip || options . limit ) {
2222 // Offset starts from 0
23- var offset = Number ( options . offset || options . skip || 0 ) ;
23+ let offset = Number ( options . offset || options . skip || 0 ) ;
2424 if ( isNaN ( offset ) ) {
2525 offset = 0 ;
2626 }
2727 limitClause = ' LIMIT ' + offset ;
2828 if ( options . limit ) {
29- var limit = Number ( options . limit ) ;
29+ let limit = Number ( options . limit ) ;
3030 if ( isNaN ( limit ) ) {
3131 limit = 0 ;
3232 }
@@ -45,7 +45,7 @@ function mixinDiscovery(MySQL, mysql) {
4545 * @returns {String } The SQL statement
4646 */
4747 MySQL . prototype . buildQuerySchemas = function ( options ) {
48- var sql = 'SELECT catalog_name as "catalog",' +
48+ const sql = 'SELECT catalog_name as "catalog",' +
4949 ' schema_name as "schema"' +
5050 ' FROM information_schema.schemata' ;
5151 return paginateSQL ( sql , 'schema_name' , options ) ;
@@ -57,8 +57,8 @@ function mixinDiscovery(MySQL, mysql) {
5757 * @returns {string } The sql statement
5858 */
5959 MySQL . prototype . buildQueryTables = function ( options ) {
60- var sqlTables = null ;
61- var schema = options . owner || options . schema ;
60+ let sqlTables = null ;
61+ const schema = options . owner || options . schema ;
6262
6363 if ( options . all && ! schema ) {
6464 sqlTables = paginateSQL ( 'SELECT \'table\' AS "type",' +
@@ -87,9 +87,9 @@ function mixinDiscovery(MySQL, mysql) {
8787 * @returns {string } The sql statement
8888 */
8989 MySQL . prototype . buildQueryViews = function ( options ) {
90- var sqlViews = null ;
90+ let sqlViews = null ;
9191 if ( options . views ) {
92- var schema = options . owner || options . schema ;
92+ const schema = options . owner || options . schema ;
9393
9494 if ( options . all && ! schema ) {
9595 sqlViews = paginateSQL ( 'SELECT \'view\' AS "type",' +
@@ -155,7 +155,7 @@ function mixinDiscovery(MySQL, mysql) {
155155 * @returns {String } The sql statement
156156 */
157157 MySQL . prototype . buildQueryColumns = function ( schema , table ) {
158- var sql = null ;
158+ let sql = null ;
159159 if ( schema ) {
160160 sql = paginateSQL ( 'SELECT table_schema AS "owner",' +
161161 ' table_name AS "tableName",' +
@@ -206,7 +206,7 @@ function mixinDiscovery(MySQL, mysql) {
206206 // http://docs.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html
207207 // #getPrimaryKeys(java.lang.String, java.lang.String, java.lang.String)
208208 MySQL . prototype . buildQueryPrimaryKeys = function ( schema , table ) {
209- var sql = 'SELECT table_schema AS "owner",' +
209+ let sql = 'SELECT table_schema AS "owner",' +
210210 ' table_name AS "tableName",' +
211211 ' column_name AS "columnName",' +
212212 ' ordinal_position AS "keySeq",' +
@@ -239,7 +239,7 @@ function mixinDiscovery(MySQL, mysql) {
239239 * @returns {string }
240240 */
241241 MySQL . prototype . buildQueryForeignKeys = function ( schema , table ) {
242- var sql =
242+ let sql =
243243 'SELECT table_schema AS "fkOwner",' +
244244 ' constraint_name AS "fkName",' +
245245 ' table_name AS "fkTableName",' +
@@ -276,7 +276,7 @@ function mixinDiscovery(MySQL, mysql) {
276276 * @returns {string }
277277 */
278278 MySQL . prototype . buildQueryExportedForeignKeys = function ( schema , table ) {
279- var sql = 'SELECT a.constraint_name AS "fkName",' +
279+ let sql = 'SELECT a.constraint_name AS "fkName",' +
280280 ' a.table_schema AS "fkOwner",' +
281281 ' a.table_name AS "fkTableName",' +
282282 ' a.column_name AS "fkColumnName",' +
@@ -306,11 +306,11 @@ function mixinDiscovery(MySQL, mysql) {
306306 */
307307
308308 MySQL . prototype . buildPropertyType = function ( columnDefinition , options ) {
309- var mysqlType = columnDefinition . dataType ;
310- var columnType = columnDefinition . columnType ;
311- var dataLength = columnDefinition . dataLength ;
309+ const mysqlType = columnDefinition . dataType ;
310+ const columnType = columnDefinition . columnType ;
311+ const dataLength = columnDefinition . dataLength ;
312312
313- var type = mysqlType . toUpperCase ( ) ;
313+ const type = mysqlType . toUpperCase ( ) ;
314314 switch ( type ) {
315315 case 'CHAR' :
316316 if ( ! options . treatCHAR1AsString && columnType === 'char(1)' ) {
@@ -379,13 +379,13 @@ function mixinDiscovery(MySQL, mysql) {
379379 // http://dev.mysql.com/doc/refman/5.7/en/numeric-type-overview.html
380380 // Currently default is the inverse of the recommendation for backward compatibility.
381381 MySQL . prototype . setDefaultOptions = function ( options ) {
382- var defaultOptions = {
382+ const defaultOptions = {
383383 treatCHAR1AsString : false ,
384384 treatBIT1AsBit : true ,
385385 treatTINYINT1AsTinyInt : true ,
386386 } ;
387387
388- for ( var opt in defaultOptions ) {
388+ for ( const opt in defaultOptions ) {
389389 if ( defaultOptions . hasOwnProperty ( opt ) && ! options . hasOwnProperty ( opt ) ) {
390390 options [ opt ] = defaultOptions [ opt ] ;
391391 }
0 commit comments