diff --git a/.github/workflows/bun-clickhouse.js.yml b/.github/workflows/bun-clickhouse.js.yml index 428190e5..1f3da331 100644 --- a/.github/workflows/bun-clickhouse.js.yml +++ b/.github/workflows/bun-clickhouse.js.yml @@ -39,9 +39,10 @@ jobs: with: bun-version: ${{ matrix.bun-version }} - run: rm -rf package-lock.json - - run: bun install - run: git submodule init - run: git submodule update + - run: bun install + - run: cd test/e2e && bun install - name: Workflow Telemetry uses: runforesight/workflow-telemetry-action@v1.8.7 if: github.event_name != 'pull_request' diff --git a/parser/bnf.js b/parser/bnf.js index 531d4817..b3dde280 100644 --- a/parser/bnf.js +++ b/parser/bnf.js @@ -70,4 +70,36 @@ for (const [name, rule] of Object.entries(compiler.languages.logql.rules)) { } } +compiler._ParseScript = compiler.ParseScript +/** + * hack to avoid ridiculously long strings + * @param script {string} + * @constructor + */ +compiler.ParseScript = function (script) { + const qLiterals = [] + const aqLiterals = [] + const quotedStrings = script.replaceAll(/"([^"\\]|\\.)+"/g, (str) => { + qLiterals.push(str) + return `"QL_${qLiterals.length - 1}"` + }) + const aQuotedStrings = quotedStrings.replaceAll(/`([^`\\]|\\.)+`/g, (str) => { + aqLiterals.push(str) + return `\`AL_${aqLiterals.length - 1}\`` + }) + const parsedScript = this._ParseScript(aQuotedStrings) + if (!parsedScript) { + return parsedScript + } + for (const t of parsedScript.rootToken.Children('QLITERAL')) { + t._value = qLiterals[parseInt(t.value.slice(4, t.value.length - 1))] + t.tokens = [] + } + for (const t of parsedScript.rootToken.Children('AQLITERAL')) { + t._value = aqLiterals[parseInt(t.value.slice(4, t.value.length - 1))] + t.tokens = [] + } + return parsedScript +} + module.exports = compiler diff --git a/test/e2e b/test/e2e index 83d70c90..85e344c8 160000 --- a/test/e2e +++ b/test/e2e @@ -1 +1 @@ -Subproject commit 83d70c90e75ba3c80315ac1a4563f2e223159da1 +Subproject commit 85e344c83efb747b123758212e216f9f6a355da2