Skip to content

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

Merged
durlabhjain merged 8 commits into
mainfrom
copilot/support-custom-function-ilike
May 26, 2026
Merged

Support ILIKE and custom case-insensitive search functions for MySQL-compatible adapters#167
durlabhjain merged 8 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) plus caseInsensitiveOrderBy and supporting helpers in Sql.
  • 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 setConfig support.

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.

Comment thread lib/business/business-base.mjs
Comment thread lib/business/business-base.mjs
Comment thread lib/sql.js Outdated
Comment thread docs/CASE_INSENSITIVE_SEARCH.md Outdated
Comment thread docs/CASE_INSENSITIVE_SEARCH.md
@durlabhjain durlabhjain requested a review from Copilot May 26, 2026 17:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread lib/sql.js
Comment thread lib/sql.js
Comment thread lib/sql.js Outdated
Comment thread tests/business-base-orderby.test.js
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@durlabhjain durlabhjain merged commit 17bc015 into main May 26, 2026
1 check passed
@durlabhjain durlabhjain deleted the copilot/support-custom-function-ilike branch May 26, 2026 20:04
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

4 participants