UNPKG

sfcc-cip-analytics-client

Version:

SFCC Commerce Intelligence Platform Analytics Client

21 lines (20 loc) 707 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatDateForSQL = formatDateForSQL; exports.cleanSQL = cleanSQL; function formatDateForSQL(date) { const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0'); return `${year}-${month}-${day}`; } /** * Apache calcite does not seem to like trailing semicolons in SQL queries * @param sql The SQL string to clean * @returns Cleaned SQL string with normalized whitespace */ function cleanSQL(sql) { // Remove trailing semicolons, matching across multiple lines sql = sql.replace(/;\s*$/, ''); return sql; }