Skip to content

Commit c71e760

Browse files
committed
fix(analytics): computed filters now have the condition
1 parent 39df8f4 commit c71e760

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/storage/adapter/common/clickHouseDialect.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,13 @@ export class ClickHouseQueryDialect implements QueryDialect {
218218
for (const condition of group.conditions) {
219219
if (condition.field === "eventType") continue;
220220
const def = FIELD_REGISTRY[table]?.[condition.field];
221-
if (!def?.chWhere) continue;
221+
222+
const colExpr = def?.chWhere || def?.chAggExpr || def?.chSelect || "NULL";
222223
const op = OPERATOR_SQL[condition.operator];
223224
if (!op) continue;
224225

225226
const paramName = `p_${paramIndex.value++}`;
226-
const paramType = def.chParamType;
227+
const paramType = def?.chParamType || "String";
227228

228229
let value: string | number = condition.value;
229230
if (
@@ -237,7 +238,7 @@ export class ClickHouseQueryDialect implements QueryDialect {
237238
}
238239

239240
params[paramName] = value;
240-
parts.push(`${def.chWhere} ${op} {${paramName}:${paramType}}`);
241+
parts.push(`${colExpr} ${op} {${paramName}:${paramType}}`);
241242
}
242243

243244
for (const subGroup of group.groups) {

src/storage/adapter/common/postgresDialect.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,14 @@ export class PostgresQueryDialect implements QueryDialect {
190190
for (const cond of group.conditions) {
191191
if (cond.field === "eventType") continue;
192192
const def = FIELD_REGISTRY[table]?.[cond.field];
193-
if (!def?.pgWhereCol) continue;
193+
194+
const colExpr =
195+
def?.pgWhereCol || def?.pgAggExpr || def?.pgSelect || "NULL";
194196
const op = OPERATOR_SQL[cond.operator];
195197
if (!op) continue;
198+
196199
parts.push(
197-
sql`${sql.raw(def.pgWhereCol)} ${sql.raw(op)} ${cond.value}${sql.raw(def.pgWhereCast)}`
200+
sql`${sql.raw(colExpr)} ${sql.raw(op)} ${cond.value}${sql.raw(def?.pgWhereCast || "")}`
198201
);
199202
}
200203

0 commit comments

Comments
 (0)