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:
+6
-1
@@ -77,7 +77,8 @@ describe('computeParameters', () => {
|
||||
expect(computeFilterParameters()).toEqual({
|
||||
name: 'filter',
|
||||
in: 'query',
|
||||
description: `Format: field[COMPARATOR]:value,field2[COMPARATOR]:value2
|
||||
description: `Format: field[COMPARATOR]:value,field2[COMPARATOR]:value2.
|
||||
For like/ilike, use % as a wildcard (e.g. %value% for substring match).
|
||||
Refer to the filter section at the top of the page for more details.`,
|
||||
required: false,
|
||||
schema: {
|
||||
@@ -97,6 +98,10 @@ describe('computeParameters', () => {
|
||||
'or(createdAt[gte]:"2024-01-01",createdAt[lte]:"2023-01-01",not(id[is]:NULL))',
|
||||
description: 'A more complex filter param',
|
||||
},
|
||||
like: {
|
||||
value: 'name[like]:"%value%"',
|
||||
description: 'Pattern matching',
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ export const baseSchema = (
|
||||
openapi: '3.1.1',
|
||||
info: {
|
||||
title: 'Twenty Api',
|
||||
description: `Use this page to explore and call the **REST API**.
|
||||
description: `Use this page to explore and call the **REST API**.
|
||||
|
||||
## Authentication
|
||||
|
||||
@@ -40,6 +40,7 @@ Use the \`filter\` query parameter to narrow results.
|
||||
- Multiple conditions: \`field1[eq]:1,field2[gte]:10\` (root conjunction is AND)
|
||||
- Composite fields: \`field.subField[COMPARATOR]:value\`
|
||||
- Common comparators: \`eq\`, \`neq\`, \`in\`, \`containsAny\`, \`is\`, \`gt\`, \`gte\`, \`lt\`, \`lte\`, \`startsWith\`, \`like\`, \`ilike\`
|
||||
- Wildcards: For \`like\`/\`ilike\`, use \`%\` as a wildcard (e.g. \`%value%\` for substring match)
|
||||
|
||||
Examples:
|
||||
|
||||
|
||||
@@ -93,7 +93,8 @@ export const computeFilterParameters = (): OpenAPIV3_1.ParameterObject => {
|
||||
return {
|
||||
name: 'filter',
|
||||
in: 'query',
|
||||
description: `Format: field[COMPARATOR]:value,field2[COMPARATOR]:value2
|
||||
description: `Format: field[COMPARATOR]:value,field2[COMPARATOR]:value2.
|
||||
For like/ilike, use % as a wildcard (e.g. %value% for substring match).
|
||||
Refer to the filter section at the top of the page for more details.`,
|
||||
required: false,
|
||||
schema: {
|
||||
@@ -113,6 +114,10 @@ export const computeFilterParameters = (): OpenAPIV3_1.ParameterObject => {
|
||||
'or(createdAt[gte]:"2024-01-01",createdAt[lte]:"2023-01-01",not(id[is]:NULL))',
|
||||
description: 'A more complex filter param',
|
||||
},
|
||||
like: {
|
||||
value: 'name[like]:"%value%"',
|
||||
description: 'Pattern matching',
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user