UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

48 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.INCLUDE = void 0; const constants_1 = require("../constants"); const utils_1 = require("../utils"); /** * `INCLUDE` Returns true if a string contains a specified sequence of characters. */ exports.INCLUDE = { identifier: 'INCLUDE', parameters: [ { identifier: 'STRING', optional: false, expectedPrimitive: constants_1.AST_PRIMITIVES.STRING, validator: [utils_1.isStringParam], }, { identifier: 'TARGET_SEARCH', optional: false, expectedPrimitive: constants_1.AST_PRIMITIVES.STRING, validator: [utils_1.isStringParam], }, ], transpiler: { elasticsearch, snowflake, redshift, postgresql, }, primitiveResult: constants_1.AST_PRIMITIVES.BOOLEAN, }; function elasticsearch(str, targetSearch) { return `INCLUDE(${str}, ${targetSearch})`; } function SQL(str, targetSearch) { return `(${str} LIKE ('%' || ${targetSearch} || '%'))`; } function snowflake(str, targetSearch) { return SQL(str, targetSearch); } function redshift(str, targetSearch) { return SQL(str, targetSearch); } function postgresql(str, targetSearch) { return SQL(str, targetSearch); } //# sourceMappingURL=include.js.map