firebird-cubejs-driver
Version:
CubeJS Firebird Driver
48 lines (47 loc) • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FirebirdQuery = void 0;
const schema_compiler_1 = require("@cubejs-backend/schema-compiler");
class FirebirdParamAllocator extends schema_compiler_1.ParamAllocator {
paramPlaceHolder(paramIndex) {
return `?`;
}
}
class FirebirdFilter extends schema_compiler_1.BaseFilter {
/**
* "ILIKE" does't support
*/
likeIgnoreCase(column, not, param, type) {
const p = (!type || type === 'contains' || type === 'ends') ? '\'%\' || ' : '';
const s = (!type || type === 'contains' || type === 'starts') ? ' || \'%\'' : '';
return `${column}${not ? ' NOT' : ''} SIMILAR TO ${p}${this.allocateParam(param)}${s}`;
}
}
class FirebirdQuery extends schema_compiler_1.BaseQuery {
sqlTemplates() {
const templates = super.sqlTemplates();
templates.params.param = '?';
return templates;
}
newParamAllocator(expressionParams) {
return new FirebirdParamAllocator(expressionParams);
}
limitOffsetClause(limit, offset) {
if ((!offset || offset == 0) && !limit)
return ``;
if (!offset || offset == 0)
offset = 1;
if (!limit)
limit = 10000;
return ` ROWS ${offset} TO ${offset + limit} `;
}
castToString(sql) {
return `CAST(${sql} as VARCHAR(32767))`;
}
//@ts-ignore
newFilter(filter) {
//@ts-ignore
return new FirebirdFilter(this, filter);
}
}
exports.FirebirdQuery = FirebirdQuery;