(expression: ComputedProjectionMathIrExpression)
| 404 | const toNumber = (expr: string) => |
| 405 | dialect.jsonColumnType === "JSON" ? `CAST(${expr} AS REAL)` : `(${expr})::numeric` |
| 406 | const compileExpr = (expression: ComputedProjectionMathIrExpression): string => { |
| 407 | switch (expression._tag) { |
| 408 | case "field": |
| 409 | return toNumber(dialect.jsonExtractElement(relationAlias, expression.field)) |
| 410 | case "mul": |
| 411 | return `(${compileExpr(expression.left)} * ${compileExpr(expression.right)})` |
| 412 | default: |
| 413 | return assertUnreachable(expression) |
| 414 | } |
| 415 | } |
| 416 | const factorCaseExpr = (unitExpr: string, toBase: string, factors: Readonly<Record<string, number>>) => { |
| 417 | const entries = Object.entries(factors).filter(([, factor]) => Number.isFinite(factor)) |
| 418 | const cases = entries.map(([unit, factor]) => ` WHEN ${sqlStringLiteral(unit)} THEN ${factor}`).join("") |
no test coverage detected
searching dependent graphs…