Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove ad-hoc filter parsing for numeric fields #629

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/data/adHocFilter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('AdHocManager', () => {
{ key: 'keyNum', operator: '=', value: '123' },
] as AdHocVariableFilter[]);
expect(val).toEqual(
`SELECT stuff FROM foo WHERE col = test settings additional_table_filters={'foo' : ' key = \\'val\\' AND keyNum = 123 '}`
`SELECT stuff FROM foo WHERE col = test settings additional_table_filters={'foo' : ' key = \\'val\\' AND keyNum = \\'123\\' '}`
);
});
it('apply ad hoc filter with no inner query and no existing WHERE', () => {
Expand All @@ -20,7 +20,7 @@ describe('AdHocManager', () => {
{ key: 'keyNum', operator: '=', value: '123' },
] as AdHocVariableFilter[]);
expect(val).toEqual(
`SELECT stuff FROM foo settings additional_table_filters={'foo' : ' key = \\'val\\' AND keyNum = 123 '}`
`SELECT stuff FROM foo settings additional_table_filters={'foo' : ' key = \\'val\\' AND keyNum = \\'123\\' '}`
);
});
it('apply ad hoc filter with an inner query without existing WHERE', () => {
Expand All @@ -31,7 +31,7 @@ describe('AdHocManager', () => {
{ key: 'keyNum', operator: '=', value: '123' },
] as AdHocVariableFilter[]);
expect(val).toEqual(
`SELECT stuff FROM (SELECT * FROM foo) as r , bar GROUP BY s ORDER BY s settings additional_table_filters={'foo' : ' key = \\'val\\' AND keyNum = 123 '}`
`SELECT stuff FROM (SELECT * FROM foo) as r , bar GROUP BY s ORDER BY s settings additional_table_filters={'foo' : ' key = \\'val\\' AND keyNum = \\'123\\' '}`
);
});
it('apply ad hoc filter with an inner from query with existing WHERE', () => {
Expand All @@ -42,7 +42,7 @@ describe('AdHocManager', () => {
{ key: 'keyNum', operator: '=', value: '123' },
] as AdHocVariableFilter[]);
expect(val).toEqual(
`SELECT stuff FROM (SELECT * FROM foo WHERE col = test) as r GROUP BY s ORDER BY s settings additional_table_filters={'foo' : ' key = \\'val\\' AND keyNum = 123 '}`
`SELECT stuff FROM (SELECT * FROM foo WHERE col = test) as r GROUP BY s ORDER BY s settings additional_table_filters={'foo' : ' key = \\'val\\' AND keyNum = \\'123\\' '}`
);
});
it('apply ad hoc filter with an inner where query with existing WHERE', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/data/adHocFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class AdHocFilter {
})
.map((f, i) => {
const key = f.key.includes('.') ? f.key.split('.')[1] : f.key;
const value = isNaN(Number(f.value)) ? `\\'${f.value}\\'` : Number(f.value);
const value = `\\'${f.value}\\'`;
const condition = i !== adHocFilters.length - 1 ? (f.condition ? f.condition : 'AND') : '';
const operator = convertOperatorToClickHouseOperator(f.operator);
return ` ${key} ${operator} ${value} ${condition}`;
Expand Down
Loading