mirror of https://github.com/apache/druid.git
change search filter to includes (#10141)
This commit is contained in:
parent
34a4113752
commit
4bb198eb4c
|
@ -50,7 +50,7 @@ describe('general', () => {
|
||||||
id: 'datasource',
|
id: 'datasource',
|
||||||
value: `hello`,
|
value: `hello`,
|
||||||
}),
|
}),
|
||||||
).toMatchInlineSnapshot(`"LOWER(\\"datasource\\") LIKE LOWER('hello%')"`);
|
).toMatchInlineSnapshot(`"LOWER(\\"datasource\\") LIKE LOWER('%hello%')"`);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
sqlQueryCustomTableFilter({
|
sqlQueryCustomTableFilter({
|
||||||
|
|
|
@ -89,7 +89,7 @@ export function makeBooleanFilter(): FilterRender {
|
||||||
|
|
||||||
interface NeedleAndMode {
|
interface NeedleAndMode {
|
||||||
needle: string;
|
needle: string;
|
||||||
mode: 'exact' | 'prefix';
|
mode: 'exact' | 'includes';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNeedleAndMode(input: string): NeedleAndMode {
|
function getNeedleAndMode(input: string): NeedleAndMode {
|
||||||
|
@ -101,7 +101,7 @@ function getNeedleAndMode(input: string): NeedleAndMode {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
needle: input.startsWith(`"`) ? input.substring(1) : input,
|
needle: input.startsWith(`"`) ? input.substring(1) : input,
|
||||||
mode: 'prefix',
|
mode: 'includes',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ export function booleanCustomTableFilter(filter: Filter, value: any): boolean {
|
||||||
if (needleAndMode.mode === 'exact') {
|
if (needleAndMode.mode === 'exact') {
|
||||||
return needle === haystack;
|
return needle === haystack;
|
||||||
}
|
}
|
||||||
return haystack.startsWith(needle);
|
return haystack.includes(needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sqlQueryCustomTableFilter(filter: Filter): string {
|
export function sqlQueryCustomTableFilter(filter: Filter): string {
|
||||||
|
@ -123,7 +123,7 @@ export function sqlQueryCustomTableFilter(filter: Filter): string {
|
||||||
if (needleAndMode.mode === 'exact') {
|
if (needleAndMode.mode === 'exact') {
|
||||||
return `${columnName} = '${needle}'`;
|
return `${columnName} = '${needle}'`;
|
||||||
} else {
|
} else {
|
||||||
return `LOWER(${columnName}) LIKE LOWER('${needle}%')`;
|
return `LOWER(${columnName}) LIKE LOWER('%${needle}%')`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue