2015-12-07 11:16:04 -05:00
|
|
|
/**
|
|
|
|
* Driver for MySQL databases
|
|
|
|
*
|
2016-09-14 16:50:32 -04:00
|
|
|
* @module drivers/Mysql
|
2015-12-07 11:16:04 -05:00
|
|
|
*/
|
2016-02-12 11:40:21 -05:00
|
|
|
module.exports = (() => {
|
2015-12-07 11:16:04 -05:00
|
|
|
delete require.cache[require.resolve('../Driver')];
|
2016-09-14 16:50:32 -04:00
|
|
|
const driver = require('../Driver');
|
2017-02-28 16:11:34 -05:00
|
|
|
const Helpers = require('../Helpers');
|
2015-12-02 13:01:31 -05:00
|
|
|
|
2015-12-07 11:16:04 -05:00
|
|
|
driver.identifierStartChar = '`';
|
|
|
|
driver.identifierEndChar = '`';
|
2015-12-02 13:01:31 -05:00
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
/**
|
2015-12-07 15:58:31 -05:00
|
|
|
* Set the limit clause
|
2016-09-14 16:50:32 -04:00
|
|
|
*
|
2015-12-07 15:58:31 -05:00
|
|
|
* @param {String} sql - SQL statement to modify
|
|
|
|
* @param {Number} limit - Maximum number of rows to fetch
|
|
|
|
* @param {Number|null} offset - Number of rows to skip
|
|
|
|
* @return {String} - Modified SQL statement
|
2015-12-03 20:43:42 -05:00
|
|
|
*/
|
2016-02-12 11:40:21 -05:00
|
|
|
driver.limit = (sql, limit, offset) => {
|
2017-02-28 16:11:34 -05:00
|
|
|
sql += (Helpers.isNumber(offset))
|
2016-09-14 16:50:32 -04:00
|
|
|
? ` LIMIT ${offset},${limit}`
|
|
|
|
: ` LIMIT ${limit}`;
|
2015-12-02 13:01:31 -05:00
|
|
|
|
2016-09-14 16:50:32 -04:00
|
|
|
return sql;
|
2015-12-07 11:16:04 -05:00
|
|
|
};
|
2015-12-02 13:01:31 -05:00
|
|
|
|
2015-12-07 11:16:04 -05:00
|
|
|
return driver;
|
2016-09-14 16:50:32 -04:00
|
|
|
})();
|