Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

fix mapfilter / rawquery for relational

Francis Caod6c8f3aa18bd
diff --git a/lib/clickhouse.ts b/lib/clickhouse.ts
index aa2f21ed3..8ce7bc980 100644
--- a/lib/clickhouse.ts
+++ b/lib/clickhouse.ts
@@ -66,7 +66,7 @@ function getDateFormat(date) {
function mapFilter(column, operator, name, type = 'String') {
switch (operator) {
case OPERATORS.equals:
- return `${column} = {${name}:${type}`;
+ return `${column} = {${name}:${type}}`;
case OPERATORS.notEquals:
return `${column} != {${name}:${type}}`;
default:
diff --git a/lib/prisma.ts b/lib/prisma.ts
index cebd71932..12bafa513 100644
--- a/lib/prisma.ts
+++ b/lib/prisma.ts
@@ -92,12 +92,12 @@ function getTimestampIntervalQuery(field: string): string {
}
}
-function mapFilter(column, operator, name, type = 'String') {
+function mapFilter(column, operator, name, type = 'varchar') {
switch (operator) {
case OPERATORS.equals:
- return `${column} = {${name}:${type}`;
+ return `${column} = {{${name}::${type}}}`;
case OPERATORS.notEquals:
- return `${column} != {${name}:${type}}`;
+ return `${column} != {{${name}::${type}}}`;
default:
return '';
}
@@ -161,7 +161,7 @@ async function rawQuery(sql: string, data: object): Promise<any> {
return Promise.reject(new Error('Unknown database.'));
}
- const query = sql?.replaceAll(/\{\{\s*(\w+)(::\w+)?\s*}}/g, (...args) => {
+ const query = sql?.replaceAll(/\{\{\s*(\w+)(::\w+)?\s*\}\}/g, (...args) => {
const [, name, type] = args;
params.push(data[name]);