Skip to content

Commit e4d4285

Browse files
committed
Fix wildcard operators
1 parent 17a5aca commit e4d4285

2 files changed

Lines changed: 60 additions & 10 deletions

File tree

package-lock.json

Lines changed: 52 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/data/adHocFilter.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ export class AdHocFilter {
3434
const filters = validFilters
3535
.map((f, i) => {
3636
const key = escapeKey(this._config, f.key);
37+
const sqlWildcardOperators = ["LIKE", "ILIKE", "NOT LIKE", "NOT ILIKE"];
38+
const operator = convertOperatorToClickHouseOperator(f.operator);
39+
// if we have wildcard operator such as LIKE, ILIKE, we need to wrap
40+
// filtered value to % for it to be valid SQL wildcard.
41+
if (sqlWildcardOperators.includes(operator)) {
42+
f.value = `%${f.value}%`;
43+
}
44+
3745
const value = escapeValueBasedOnOperator(f.value, f.operator);
3846
const condition = i !== validFilters.length - 1 ? (f.condition ? f.condition : 'AND') : '';
39-
const operator = convertOperatorToClickHouseOperator(f.operator);
4047
return ` ${key} ${operator} ${value} ${condition}`;
4148
})
4249
.join('');

0 commit comments

Comments
 (0)