Skip to content

fix(search): quote column names in ILIKE to unblock Newman tests#1437

Merged
WilcoLouwerse merged 2 commits intodevelopmentfrom
fix/newman-postgres-like-quoting
May 7, 2026
Merged

fix(search): quote column names in ILIKE to unblock Newman tests#1437
WilcoLouwerse merged 2 commits intodevelopmentfrom
fix/newman-postgres-like-quoting

Conversation

@rubenvdlinde
Copy link
Copy Markdown
Contributor

Summary

MagicSearchHandler interpolates raw column names into ILIKE conditions. When a schema uses a PostgreSQL reserved word (case, status, …) as a property, this produces:

ERROR: syntax error at or near "LIKE" at character 16

…which fails Newman integration tests across the board (development, all open feature PRs).

Fix

Wrap the column with "..." on Postgres / `...` on MySQL before interpolating into the ILIKE/LIKE clause. One file, one method.

Origin

Cherry-pick of the search-quoting half of 4a724d8af. The linked-types serialization half of that older commit is dropped — dev's ObjectEntity::getObjectArray() no longer prefixes _mail/_contacts/etc. with an underscore, so re-applying it would regress.

Test plan

  • Newman job goes green on this branch
  • Existing PHPUnit search tests still pass

PostgreSQL reserved words (e.g. `case`, `status`) used as column names
break ILIKE search with `syntax error at or near "LIKE"`. Wrap the
column with `"..."` on Postgres / `` `...` `` on MySQL before
interpolating into the ILIKE/LIKE clause.

Unblocks Newman integration tests on development and any branch where
schemas use reserved words as property names.

Cherry-pick of the search-quoting half of 4a724d8 (the linked-types
serialization half is dropped — dev no longer prefixes those columns
with `_`).
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Quality Report — ConductionNL/openregister @ d266206

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
composer ✅ 147/147
npm ✅ 598/598
PHPUnit ⏭️
Newman ⏭️
Playwright ⏭️

Quality workflow — 2026-05-07 07:56 UTC

Download the full PDF report from the workflow artifacts.

Comment thread lib/Db/MagicMapper/MagicSearchHandler.php Outdated
Comment thread lib/Db/MagicMapper/MagicSearchHandler.php Outdated
Comment thread lib/Db/MagicMapper/MagicSearchHandler.php Outdated
Comment thread lib/Db/MagicMapper/MagicSearchHandler.php Outdated
Comment thread lib/Db/MagicMapper/MagicSearchHandler.php Outdated
Comment thread lib/Db/MagicMapper/MagicSearchHandler.php Outdated
Comment thread lib/Db/MagicMapper/MagicSearchHandler.php Outdated
Copy link
Copy Markdown
Contributor

@WilcoLouwerse WilcoLouwerse left a comment

Choose a reason for hiding this comment

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

2 blockers require fixes before merge — the fix is incomplete (applyFullTextSearch at line 1199 has the same unquoted column reference) and phpcs CI is failing. Three concerns to address: extract a quoteIdentifier helper, the MySQL branch drops the ::text cast and LOWER wrapping, and add a regression test for reserved-word property names. The platform detection and quoting strategy in buildSearchConditionSql are otherwise sound.

…en MySQL search

Addresses PR #1437 review:

* Extract private quoteIdentifier()/isPostgresPlatform() helpers, mirroring
  the convention in MagicMapper and the rest of the codebase.
* Apply quoting to applyFullTextSearch(), which used the same unquoted
  column interpolation as buildSearchConditionSql() and would still crash
  on PostgreSQL with reserved-word properties (case, status, ...).
* MySQL branch now uses LOWER(CAST(`col` AS CHAR)) LIKE LOWER(...) so
  search stays case-insensitive on utf8mb4_bin and matches the behaviour
  of applyFullTextSearch().
* Detect platform once in buildWhereConditionsSql() and thread $isPostgres
  into buildSearchConditionSql() instead of recomputing per UNION arm.
* Align hasPgTrgmExtension() to the codebase-standard idiom for platform
  detection.
* Add PHPUnit regression coverage asserting reserved-word properties get
  quoted on both PostgreSQL and MySQL.
* Restore phpcs end-comments dropped by the earlier ternary refactor;
  phpcs is clean on the modified file (the unrelated long-line warning at
  the existing line is pre-existing).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@WilcoLouwerse WilcoLouwerse left a comment

Choose a reason for hiding this comment

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

All 7 prior findings resolved in 631c1ff — verified against the diff:

Newman is green, no new findings. Ship it.

@WilcoLouwerse WilcoLouwerse merged commit 9743637 into development May 7, 2026
1 check passed
@WilcoLouwerse WilcoLouwerse deleted the fix/newman-postgres-like-quoting branch May 7, 2026 11:08
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.

3 participants