Support ILIKE and custom case-insensitive search functions for MySQL-compatible adapters#167
Conversation
Agent-Logs-Url: https://github.com/durlabhjain/dframework-node/sessions/fb6a8b74-6817-4be8-9ea3-a570402f349e Co-authored-by: durlabhjain <18685657+durlabhjain@users.noreply.github.com>
…BY support Agent-Logs-Url: https://github.com/durlabhjain/dframework-node/sessions/fb6a8b74-6817-4be8-9ea3-a570402f349e Co-authored-by: durlabhjain <18685657+durlabhjain@users.noreply.github.com>
Agent-Logs-Url: https://github.com/durlabhjain/dframework-node/sessions/4e294b8b-7baf-4ae9-9329-12ae07b3a1c7 Co-authored-by: durlabhjain <18685657+durlabhjain@users.noreply.github.com>
…fy ORDER BY sanitize-then-wrap comment Agent-Logs-Url: https://github.com/durlabhjain/dframework-node/sessions/4e294b8b-7baf-4ae9-9329-12ae07b3a1c7 Co-authored-by: durlabhjain <18685657+durlabhjain@users.noreply.github.com>
|
I've verified the changes
I analyzed the final generated query, ILIKE function is not used in the where part of the query, it still maintains the "UPPER(Name) Like ". We also also add a ReadMe.md file too so backend application can kow how effectively apply the needed changes. caseInsensitiveMode: 'ilike-fn' was added to the mysqlConfig |
|
@copilot Update documentation/ examples on how different features can be activated for comparisons and how do they work in an application |
…E_CONFIGURATION Agent-Logs-Url: https://github.com/durlabhjain/dframework-node/sessions/69e06114-39cb-48ca-8b1d-2d642f97bfb0 Co-authored-by: durlabhjain <18685657+durlabhjain@users.noreply.github.com>
The root cause of filtering not working with await mysql.setConfig({
host: '...', user: '...', password: '...', database: '...',
namedPlaceholders: true,
forceCaseInsensitive: true, // ← required — without this no transformation is applied
caseInsensitiveMode: 'ilike-fn', // ← selects ILIKE(field, :param) = 1 syntax
});Without Added a full guide with troubleshooting at
Added
Also updated |
There was a problem hiding this comment.
Pull request overview
This PR extends DFramework’s configurable case-insensitive filtering/sorting to better support MySQL-compatible adapters (notably StarRocks) by adding an ilike-fn mode and configurable ORDER BY case handling, along with documentation and tests.
Changes:
- Added
caseInsensitiveMode: 'ilike-fn'(ILIKE function-call form) pluscaseInsensitiveOrderByand supporting helpers inSql. - Fixed/updated
BusinessBase.list()ORDER BY construction to sanitize per-field and apply optional case-insensitive wrapping. - Added/updated docs and a comprehensive test suite for case-insensitive modes, ORDER BY wrapping, and
setConfigsupport.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/case-insensitive.test.js | Adds coverage for applyCaseInsensitive modes (upper/ilike/ilike-fn/custom), ORDER BY wrapping, shadow columns, and setConfig. |
| README.md | Adds a documentation link for case-insensitive search/sorting. |
| lib/sql.js | Implements ilike-fn statement-template support, adds ORDER BY case handling config, and updates parameter binding logic. |
| lib/business/business-base.mjs | Reworks ORDER BY building (per-field sanitize + optional wrapping) and integrates shadow column substitution. |
| docs/DATABASE_CONFIGURATION.md | Documents new configuration options and provides a StarRocks example. |
| docs/CASE_INSENSITIVE_SEARCH.md | New end-to-end guide for modes, ORDER BY options, and troubleshooting. |
caseInsensitiveMode/shadowColumns/applyCaseInsensitive/applyShadowColumnscode'ilike-fn'mode toapplyCaseInsensitive→ returns{ statementTemplate: 'ILIKE(field, {param}) = 1', value }for StarRocks function-call syntaxaddParametersto handlestatementTemplatereturn (bind param normally, push custom statement with{param}replaced)caseInsensitiveOrderBy = falseproperty +setConfigsupportapplyOrderByCaseInsensitive(fieldName)method (false = no-op, true/'upper' = UPPER wrap, function = custom)applyOrderByCaseInsensitive, remove the double-sanitize bug on the joined string'ilike-fn'mode,applyOrderByCaseInsensitive,setConfig caseInsensitiveOrderBy