Add wildcard documentation for like/ilike/containsIlike filters (#17825)
Add documentation for issue #16602 After discussing with the team (Thomas), https://discord.com/channels/1130383047699738754/1443986309436936212 we decided that updating the documentation. The issue is In compute-where-condition-parts.ts, the like/ilike cases pass values directly to SQL without adding % wildcards for api using, so they behave like exact matches. This PR updates the documentation regarding the use of `like`, `ilike` and `containsIlike` filters. Instead of auto-wrapping values with % wildcards in the backend, we are choosing to leave the control to the API users (%value% or value%). <img width="651" height="409" alt="image" src="https://github.com/user-attachments/assets/b3537af6-a0b0-4fff-a86d-a9ae334d628e" /> But I add wildcard for `startsWith` and `endsWith` because these operators have a fixed semantic meaning. (To see the results, please refresh the cache first, then restart the server.) <img width="878" height="458" alt="image" src="https://github.com/user-attachments/assets/ab0f4e7c-df50-45ef-b1c8-e43c8881a9a3" /><img width="482" height="288" alt="image" src="https://github.com/user-attachments/assets/20dc39ee-2417-4ecc-810e-ea0ead33d803" /> --------- Co-authored-by: Thomas Trompette <thomas.trompette@sfr.fr>
This commit is contained in:
co-authored by
Thomas Trompette
parent
1e01f15182
commit
52e57e70fd
+2
-2
@@ -110,12 +110,12 @@ export const computeWhereConditionParts = ({
|
||||
};
|
||||
case 'startsWith':
|
||||
return {
|
||||
sql: `${fieldReference}::text LIKE :${key}${uuid}`,
|
||||
sql: `${fieldReference}::text ^@ :${key}${uuid}`,
|
||||
params: { [`${key}${uuid}`]: `${value}` },
|
||||
};
|
||||
case 'endsWith':
|
||||
return {
|
||||
sql: `${fieldReference}::text LIKE :${key}${uuid}`,
|
||||
sql: `RIGHT(${fieldReference}::text, LENGTH(:${key}${uuid})) = :${key}${uuid}`,
|
||||
params: { [`${key}${uuid}`]: `${value}` },
|
||||
};
|
||||
case 'contains':
|
||||
|
||||
+4
-1
@@ -5,7 +5,10 @@ import { FilterIs } from 'src/engine/api/graphql/workspace-schema-builder/graphq
|
||||
export const ArrayFilterType = new GraphQLInputObjectType({
|
||||
name: 'ArrayFilter',
|
||||
fields: {
|
||||
containsIlike: { type: GraphQLString },
|
||||
containsIlike: {
|
||||
type: GraphQLString,
|
||||
description: 'Case-insensitive match with % wildcard (e.g. %value%)',
|
||||
},
|
||||
is: { type: FilterIs },
|
||||
isEmptyArray: { type: GraphQLBoolean },
|
||||
},
|
||||
|
||||
+4
-1
@@ -6,6 +6,9 @@ export const RawJsonFilterType = new GraphQLInputObjectType({
|
||||
name: 'RawJsonFilter',
|
||||
fields: {
|
||||
is: { type: FilterIs },
|
||||
like: { type: GraphQLString },
|
||||
like: {
|
||||
type: GraphQLString,
|
||||
description: 'Pattern match with % wildcard (e.g. %value%)',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
+4
-1
@@ -3,7 +3,10 @@ import { GraphQLInputObjectType, GraphQLString } from 'graphql';
|
||||
const richTextV2LeafFilter = new GraphQLInputObjectType({
|
||||
name: 'RichTextV2LeafFilter',
|
||||
fields: {
|
||||
ilike: { type: GraphQLString },
|
||||
ilike: {
|
||||
type: GraphQLString,
|
||||
description: 'Case-insensitive match with % wildcard (e.g. %value%)',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
+9
-2
@@ -18,8 +18,15 @@ export const StringFilterType = new GraphQLInputObjectType({
|
||||
lte: { type: GraphQLString },
|
||||
neq: { type: GraphQLString },
|
||||
startsWith: { type: GraphQLString },
|
||||
like: { type: GraphQLString },
|
||||
ilike: { type: GraphQLString },
|
||||
endsWith: { type: GraphQLString },
|
||||
like: {
|
||||
type: GraphQLString,
|
||||
description: 'Pattern match with % wildcard (e.g. %value%)',
|
||||
},
|
||||
ilike: {
|
||||
type: GraphQLString,
|
||||
description: 'Case-insensitive match with % wildcard (e.g. %value%)',
|
||||
},
|
||||
regex: { type: GraphQLString },
|
||||
iregex: { type: GraphQLString },
|
||||
is: { type: FilterIs },
|
||||
|
||||
+1
@@ -11,6 +11,7 @@ export enum FilterComparators {
|
||||
lt = 'lt',
|
||||
lte = 'lte',
|
||||
startsWith = 'startsWith',
|
||||
endsWith = 'endsWith',
|
||||
like = 'like',
|
||||
ilike = 'ilike',
|
||||
|
||||
|
||||
Reference in New Issue
Block a user