All files / lib/drivers Mysql.js

80% Statements 8/10
0% Branches 0/2
50% Functions 1/2
80% Lines 8/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32          1x 1x 1x 1x   1x 1x                   1x               1x    
/**
 * Driver for MySQL databases
 *
 * @module drivers/Mysql
 */
module.exports = (() => {
	delete require.cache[require.resolve('../Driver')];
	const driver = require('../Driver');
	const Helpers = require('../Helpers');
 
	driver.identifierStartChar = '`';
	driver.identifierEndChar = '`';
 
	/**
	 * Set the limit clause
	 *
	 * @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
	 */
	driver.limit = (sql, limit, offset) => {
		sql += (Helpers.isNumber(offset))
			? ` LIMIT ${offset},${limit}`
			: ` LIMIT ${limit}`;
 
		return sql;
	};
 
	return driver;
})();