2015-12-07 17:03:36 -05:00
|
|
|
'use strict';
|
2015-12-02 13:01:31 -05:00
|
|
|
|
2015-12-07 12:03:42 -05:00
|
|
|
let helpers = require('../helpers');
|
2015-12-02 13:01:31 -05:00
|
|
|
|
2015-12-07 11:16:04 -05:00
|
|
|
/**
|
|
|
|
* Driver for Firebird databases
|
|
|
|
*
|
|
|
|
* @module drivers/firebird
|
|
|
|
*/
|
2016-02-12 11:40:21 -05:00
|
|
|
module.exports = (() => {
|
2015-12-07 11:16:04 -05:00
|
|
|
delete require.cache[require.resolve('../Driver')];
|
2015-12-07 12:03:42 -05:00
|
|
|
let driver = require('../Driver');
|
2015-12-07 11:16:04 -05:00
|
|
|
|
|
|
|
driver.hasTruncate = false;
|
2015-12-02 13:01:31 -05:00
|
|
|
|
|
|
|
/**
|
2015-12-07 15:58:31 -05:00
|
|
|
* Set the limit clause
|
|
|
|
|
|
|
|
* @param {String} origSql - 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 = (origSql, limit, offset) => {
|
2015-12-07 15:58:31 -05:00
|
|
|
let sql = `FIRST ${limit}`;
|
2015-12-03 20:43:42 -05:00
|
|
|
|
|
|
|
if (helpers.isNumber(offset))
|
|
|
|
{
|
2015-12-07 15:58:31 -05:00
|
|
|
sql += ` SKIP ${offset}`;
|
2015-12-02 13:01:31 -05:00
|
|
|
}
|
|
|
|
|
2015-12-07 15:58:31 -05:00
|
|
|
return origSql.replace(/SELECT/i, `SELECT ${sql}`);
|
2015-12-07 11:16:04 -05:00
|
|
|
};
|
2015-12-02 13:01:31 -05:00
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
/**
|
|
|
|
* SQL to insert a group of rows
|
|
|
|
*
|
2015-12-07 15:58:31 -05:00
|
|
|
* @return {void}
|
|
|
|
* @throws {Error}
|
2015-12-03 20:43:42 -05:00
|
|
|
*/
|
2016-02-12 11:40:21 -05:00
|
|
|
driver.insertBatch = () => {
|
2015-12-07 17:03:36 -05:00
|
|
|
throw new Error('Not Implemented');
|
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-02-12 11:40:21 -05:00
|
|
|
})();
|