diff --git a/.deno/evaluator.ts b/.deno/evaluator.ts index d3edb1b..5dd7395 100644 --- a/.deno/evaluator.ts +++ b/.deno/evaluator.ts @@ -26,7 +26,7 @@ export class Evaluator implements IValue { } get isConstant(): boolean { - return !this.usedColumns.size && !this.forceNotConstant; + return !this.usedColumns.size && !this.forceNotConstant || !!this.opts?.actAsConstantLiteral; } get isConstantReal(): boolean { @@ -51,29 +51,24 @@ export class Evaluator implements IValue { } // fetch columns to depend on - let depArray: IValue[] | undefined = undefined; + let depArray: IValue[] | nil = dependencies && !Array.isArray(dependencies) + ? [dependencies] + : dependencies; let hasNotConstant = false; - if (dependencies) { - if (!Array.isArray(dependencies)) { - depArray = [dependencies]; - this.usedColumns = dependencies.usedColumns as Set; - hasNotConstant = !dependencies.isConstant; - this.origin = dependencies.origin; - } else { - this.usedColumns = new Set(); - for (const d of dependencies) { - if (d.origin) { - if (this.origin && d.origin && this.origin !== d.origin) { - throw new Error('You cannot evaluate an expression which is coming from multiple origins'); - } - this.origin = d.origin; - } - if (!d.isConstant) { - hasNotConstant = true; - } - for (const u of d.usedColumns) { - this.usedColumns.add(u); + if (depArray) { + this.usedColumns = new Set(); + for (const d of depArray) { + if (d.origin) { + if (this.origin && d.origin && this.origin !== d.origin) { + throw new Error('You cannot evaluate an expression which is coming from multiple origins'); } + this.origin = d.origin; + } + if (!d.isConstant) { + hasNotConstant = true; + } + for (const u of d.usedColumns) { + this.usedColumns.add(u); } } } diff --git a/.deno/parser/expression-builder.ts b/.deno/parser/expression-builder.ts index fe3428c..867fb57 100644 --- a/.deno/parser/expression-builder.ts +++ b/.deno/parser/expression-builder.ts @@ -154,6 +154,7 @@ function _buildValueReal(val: Expr): IValue { , { forceNotConstant: true, actAsConstantLiteral: true, + unpure: true, onCast: toType => { // register the type of the parameter setParameterType(idx, toType);