Skip to content

Support ILIKE and custom case-insensitive search functions for MySQL-compatible adapters#167

Draft
Copilot wants to merge 6 commits into
mainfrom
copilot/support-custom-function-ilike
Draft

Support ILIKE and custom case-insensitive search functions for MySQL-compatible adapters#167
Copilot wants to merge 6 commits into
mainfrom
copilot/support-custom-function-ilike

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

  • Understand existing caseInsensitiveMode / shadowColumns / applyCaseInsensitive / applyShadowColumns code
  • sql.js: Add 'ilike-fn' mode to applyCaseInsensitive → returns { statementTemplate: 'ILIKE(field, {param}) = 1', value } for StarRocks function-call syntax
  • sql.js: Update addParameters to handle statementTemplate return (bind param normally, push custom statement with {param} replaced)
  • sql.js: Add caseInsensitiveOrderBy = false property + setConfig support
  • sql.js: Add applyOrderByCaseInsensitive(fieldName) method (false = no-op, true/'upper' = UPPER wrap, function = custom)
  • business-base.mjs: Fix ORDER BY construction — parse field/direction separately, sanitize field name part, then apply applyOrderByCaseInsensitive, remove the double-sanitize bug on the joined string
  • tests/case-insensitive.test.js: Tests for 'ilike-fn' mode, applyOrderByCaseInsensitive, setConfig caseInsensitiveOrderBy
  • Code review: removed non-standard operators (CONTAINS/STARTSWITH/ENDSWITH) from ilike-fn sets; added comment in business-base clarifying sanitize-then-wrap order
  • All 41 case-insensitive tests pass; CodeQL: 0 alerts

Copilot AI changed the title [WIP] Support custom function/ILIKE for case insensitive searches in MySQL Support ILIKE and custom case-insensitive search functions for MySQL-compatible adapters May 16, 2026
Copilot AI requested a review from durlabhjain May 16, 2026 12:10
Copilot AI and others added 2 commits May 16, 2026 12:43
…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>
@precious-ndamati-stream4Tech
Copy link
Copy Markdown
Collaborator

precious-ndamati-stream4Tech commented May 16, 2026

I've verified the changes

  1. filtering is not working - no record was returned
  2. Sorting works fine

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

@durlabhjain
Copy link
Copy Markdown
Owner

@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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 20, 2026

I've verified the changes

  1. filtering is not working - no record was returned
    ...

The root cause of filtering not working with caseInsensitiveMode: 'ilike-fn' is a missing forceCaseInsensitive: true. The mode is only activated when that master switch is set. You need both in the same setConfig call:

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 forceCaseInsensitive: true, the default 'upper' mode produces UPPER(Name) LIKE :Name for any existing forceCaseInsensitive setting elsewhere.

Added a full guide with troubleshooting at docs/CASE_INSENSITIVE_SEARCH.md (commit d91e295).

@copilot Update documentation/ examples on how different features can be activated for comparisons and how do they work in an application

Added docs/CASE_INSENSITIVE_SEARCH.md (commit d91e295) covering:

  • Master switchforceCaseInsensitive (must be true to activate any mode)
  • Comparison modes'upper' (MSSQL default), 'ilike' (PostgreSQL infix), 'ilike-fn' (StarRocks function syntax), and custom function
  • ORDER BYcaseInsensitiveOrderBy (false / true / custom function)
  • Shadow columns — pre-computed sort columns as an alternative to function wrapping
  • Full config examples for MSSQL, MySQL, StarRocks, and PostgreSQL
  • BusinessBase / Framework integration example
  • Troubleshooting section (filters returning no rows, still seeing UPPER(), etc.)

Also updated README.md and docs/DATABASE_CONFIGURATION.md with a quick-start snippet and a link to the guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom function/ ILIKE for case insensitive searches in MySQL

3 participants