diff --git a/packages/query-composer/src/core/filters.ts b/packages/query-composer/src/core/filters.ts index f543ba2a..14688cf6 100644 --- a/packages/query-composer/src/core/filters.ts +++ b/packages/query-composer/src/core/filters.ts @@ -225,7 +225,7 @@ export function timeFilterToString(field: string, filter: TimeFilter): string { const quotedField = maybeQuoteIdentifier(field); switch (filter.type) { case 'is_in_the_past': - return `${quotedField}: now - ${filter.amount} ${filter.unit} for ${filter.amount} ${filter.unit}`; + return `${quotedField} ? now - ${filter.amount} ${filter.unit} for ${filter.amount} ${filter.unit}`; case 'is_last': return `${quotedField}.${filter.period} = now.${filter.period} - 1 ${filter.period}`; case 'is_this': @@ -260,7 +260,7 @@ export function timeFilterToString(field: string, filter: TimeFilter): string { return `${quotedField} != null`; case 'custom': default: - return `${quotedField}: ${filter.partial}`; + return `${quotedField} ? ${filter.partial}`; } } @@ -551,7 +551,7 @@ const NUM_GTE_FILTER = new RegExp(`^(${FIELD})\\s*>=\\s*(${NUMBER})$`); const TIME_UNIT = `(?:year|quarter|month|week|day|hour|minute|second)`; const TIME_PAST_FILTER = new RegExp( - `^(${FIELD})\\s*:\\s*now\\s*-\\s*(${NUMBER})\\s*(${TIME_UNIT})s?\\s*for\\s*\\s*(${NUMBER})\\s*(${TIME_UNIT})s?$` + `^(${FIELD})\\s*\\?\\s*now\\s*-\\s*(${NUMBER})\\s*(${TIME_UNIT})s?\\s*for\\s*\\s*(${NUMBER})\\s*(${TIME_UNIT})s?$` ); const TIME_LAST_FILTER = new RegExp( `^(${FIELD})\\.(${TIME_UNIT})\\s*=\\s*now\\.(${TIME_UNIT})\\s*-\\s*1\\s*(${TIME_UNIT})$` diff --git a/packages/query-composer/tests/core/filters.spec.ts b/packages/query-composer/tests/core/filters.spec.ts index 0bc74ae7..0ec49822 100644 --- a/packages/query-composer/tests/core/filters.spec.ts +++ b/packages/query-composer/tests/core/filters.spec.ts @@ -110,7 +110,7 @@ const TIME_FILTER_TO_STRING: [TimeFilter, string][] = [ ], [ {type: 'is_in_the_past', amount: 1, unit: 'days'}, - 'a: now - 1 days for 1 days', + 'a ? now - 1 days for 1 days', ], [{type: 'is_last', period: 'day'}, 'a.day = now.day - 1 day'], [{type: 'is_null'}, 'a = null'],