@qrvey/formula-lang
Version:
QFormula support for qrvey projects
54 lines • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.REPLACE = void 0;
const constants_1 = require("../constants");
const utils_1 = require("../utils");
/**
* `REPLACE` Returns the string give it in lower case.
*/
exports.REPLACE = {
identifier: 'REPLACE',
parameters: [
{
identifier: 'STRING',
optional: false,
expectedPrimitive: constants_1.AST_PRIMITIVES.STRING,
validator: [utils_1.isStringParam],
},
{
identifier: 'TARGET',
optional: false,
expectedPrimitive: constants_1.AST_PRIMITIVES.STRING,
validator: [utils_1.isStringParam],
},
{
identifier: 'REPLACEMENT',
optional: false,
expectedPrimitive: constants_1.AST_PRIMITIVES.STRING,
validator: [utils_1.isStringParam],
},
],
transpiler: {
elasticsearch,
snowflake,
redshift,
postgresql,
},
primitiveResult: constants_1.AST_PRIMITIVES.STRING,
};
function elasticsearch(str, target, replacement) {
return `REPLACE(${str}, ${target}, ${replacement})`;
}
function SQL(str, target, replacement) {
return `REPLACE(${str}, ${target}, ${replacement})`;
}
function snowflake(str, target, replacement) {
return SQL(str, target, replacement);
}
function redshift(str, target, replacement) {
return SQL(str, target, replacement);
}
function postgresql(str, target, replacement) {
return SQL(str, target, replacement);
}
//# sourceMappingURL=replace.js.map