Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

fix(MagicMapper): CAST(col AS CHAR) for MariaDB in UNION queries#1291

Merged
remko48 merged 7 commits into
developmentfrom
feature/git-1272/backwards-compatibility-multischemas
Apr 20, 2026
Merged

fix(MagicMapper): CAST(col AS CHAR) for MariaDB in UNION queries#1291
remko48 merged 7 commits into
developmentfrom
feature/git-1272/backwards-compatibility-multischemas

Conversation

@remko48

@remko48 remko48 commented Apr 20, 2026

Copy link
Copy Markdown
Member

Fix: MariaDB 500 error when fetching publications from a multi-schema catalog

Problem

When a catalog contained more than one schema, fetching publications failed with:

SQLSTATE[42000]: Syntax error or access violation: 1064
You have an error in your SQL syntax … near '::text AS `title`,
`kenmerk`::text AS `kenmerk`, `publicatiedatum`::text …'

Multi-schema catalogs trigger a UNION query so that results from every schema's table can be combined in a single result set. Each SELECT arm must expose the same columns, so buildUnionSelectPart() casts every column to a common text type. The method correctly detected the database platform ($isPostgres), but then ignored that flag and hardcoded PostgreSQL's ::text cast syntax unconditionally — syntax that MariaDB does not support.

Root cause

buildUnionSelectPart() in MagicMapper.php:

// before — always emits ::text regardless of database
$colExpr = "NULL::text AS {$quotedCol}";
$colExpr = "{$quotedCol}::text AS {$quotedCol}";

The same pattern already existed correctly in MagicFacetHandler.php, which uses CAST(x AS CHAR) for MariaDB and x::text only for PostgreSQL.

Fix

Both the column cast expressions and the search relevance score expressions now branch on $isPostgres:

Database Column cast Search score
PostgreSQL col::text ILIKE / similarity() (pg_trgm)
MariaDB/MySQL CAST(col AS CHAR) LIKE

Files changed

  • lib/Db/MagicMapper.phpbuildUnionSelectPart(): column casts and search score expressions are now database-aware

@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ c2f3aeb

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

Quality workflow — 2026-04-20 08:42 UTC

Download the full PDF report from the workflow artifacts.

@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 827ad9e

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

Quality workflow — 2026-04-20 08:58 UTC

Download the full PDF report from the workflow artifacts.

bbrands02
bbrands02 previously approved these changes Apr 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 5008d05

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

Quality workflow — 2026-04-20 09:48 UTC

Download the full PDF report from the workflow artifacts.

@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ b4287f7

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

Quality workflow — 2026-04-20 09:51 UTC

Download the full PDF report from the workflow artifacts.

@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ fb68ade

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

Quality workflow — 2026-04-20 09:57 UTC

Download the full PDF report from the workflow artifacts.

@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 0227258

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

Quality workflow — 2026-04-20 12:03 UTC

Download the full PDF report from the workflow artifacts.

@remko48 remko48 merged commit 4e9543f into development Apr 20, 2026
33 of 41 checks passed
@remko48 remko48 deleted the feature/git-1272/backwards-compatibility-multischemas branch April 20, 2026 13:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants