Skip to content

fix(import): import preview rows use source_row, row_number is reserved on MariaDB (beta) - #5957

Merged
WilcoLouwerse merged 9 commits into
betafrom
hotfix/beta-4909-mariadb-row-number
Nov 6, 2026
Merged

WilcoLouwerse merged 9 commits into
betafrom
hotfix/beta-4909-mariadb-row-number

Conversation

@WilcoLouwerse

@WilcoLouwerse WilcoLouwerse commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Backport of #5879 (merged into development on 6 November) to beta, plus two tests. This fixes #4909 on beta, and the App Store beta is built from beta.

Version1Date20260915050000 created openregister_import_preview_rows with a column row_number. That word is reserved on MariaDB, and Doctrine DBAL does not quote it there: row_number is missing from DBAL's MariaDB keyword list, while its MySQL 8 list has it. So every MariaDB install, fresh or upgrading, stopped with SQLSTATE[42000] 1064 … near 'row_number'.

  • 8f5838c24b and cbc50fe247 from fix(import): import preview rows use source_row, row_number is reserved on MariaDB #5879 are cherry-picked with -x. Version1Date20260915050000 now creates source_row. The new Version1Date20261106120000 renames an existing row_number with one quoted RENAME COLUMN, so the rows and idx_or_improw_unique stay. ImportPreviewRow and its mapper follow the new name, and the JSON key row is unchanged.
  • The migration, the entity, the migration test and Version1Date20260915050000 are byte-identical to development. So the next beta → development sync carries the same class under the same name.
  • Not taken from fix(import): import preview rows use source_row, row_number is reserved on MariaDB #5879: tests/Unit/Db/fixtures/mapper-paging-golden.json, which does not exist on beta. The <version> is set beta-style, to 2.1.42-beta.20261106120000.
  • New ImportPreviewRowMapperMigratedTest runs the mapper's queries as real SQL against the table the migrations create. It checks that the table has source_row and not row_number, and that rows come back in source order.
  • New ReservedColumnNamesTest checks every migrated column against the words MariaDB 11.3 and MySQL 8.0 refuse unquoted. These lists were measured on those servers (tests/Unit/Migration/fixtures/). The reserved names already in use, which DBAL does quote, are listed as known exceptions: cursor, groups, limit, offset, schema, schemas and trigger.

The first push of this branch had its own fix with row_no, written before I saw #5879. It is reverted in afe626ea48, so beta and development end up with the same column.

MySQL 8 was not affected by row_number, because DBAL quotes it there. A fresh MySQL 8 install still fails earlier, on #4311 (a JSON column with a default value); that is outside this PR.

Checks

  • Ran, on NC 35.0.2 + MariaDB 11.3 with the 2.1.42-beta tarball plus this branch:

    • fresh install;
    • a retry after a failed fresh install;
    • an upgrade from the failed-update state on directory.opencatalogi.nl (simulated: tables dropped, migration unrecorded, installed_version lowered);
    • the hand-made workaround tables with rows (renamed, rows and index kept);
    • an import preview and a commit afterwards (3 objects).

    Without the fix, the fresh install and the upgrade reproduce the 1064. OpenCatalogi 2.1.42-beta.20261106064323 was enabled alongside.

  • Ran, on NC 35.0.2 + PostgreSQL 16: an upgrade from the 2.1.42-beta with rows in row_number (renamed, rows and index kept).

  • Review fix 1f079e7cca (fix(import): import preview rows use source_row, row_number is reserved on MariaDB (beta) #5957 f3): the reserved-word allowance comment now says where Doctrine quotes each word; ReservedColumnNamesTest green after it.

  • Ran: the import-preview tests, the controller test, Version1Date20261106120000Test, SchemaReuseHygieneTest and the two new tests, 52 tests, all green. With the old column name put back, the mapper test (4 tests) and ReservedColumnNamesTest fail. That check ran on the first push's variant of the fix.

  • Ran, on the first push's variant of the fix: the full Unit suite in a NC 35 container, 29151 tests. The only ones that did not pass need what that container lacks: MigrationVersionBumpCheckTest (7, no git) and ChunkMapperLiveQueryTest (5, no oc_openregister_chunks table). It was not re-run after the switch to the backport.

  • Ran: check:migration-version (OK). Ran on the first push: composer phpcs, phpmd and phpstan, all green.

  • Not run: psalm crashed locally inside its own ConstantTypeResolver (PHP 8.4), so it gives no verdict; CI runs it.

  • Inherited, not touched: hydra gate 67 (openregister-contract-parity) is red on lib/Contract/EmailLinkReaderInterface.php on beta itself.

Test plan

Fixes #4909 on beta. beta is not the default branch, so merging does not close the issue: it is closed by hand once the beta release is verified.

🤖 Generated with Claude Code

WilcoLouwerse and others added 3 commits November 6, 2026 15:42
…riaDB

`row_number` is a reserved word on MariaDB, and Doctrine does not quote
it there because its MariaDB keyword list lacks the word. The CREATE
TABLE in Version1Date20260915050000 therefore failed with error 1064 on
every MariaDB install, fresh or upgrading.

- Version1Date20260915050000 now creates `row_no`.
- Version1Date20261106120000 renames an existing `row_number` (PostgreSQL,
  SQLite, MySQL 8, and MariaDB tables created by hand as a workaround)
  with one quoted RENAME COLUMN, so the rows and the unique index stay.
- ImportPreviewRow, its mapper and ImportPreviewService use `rowNo`; the
  JSON key `row` is unchanged.
- ReservedColumnNamesTest checks every migrated column against the
  reserved words measured on MariaDB 11.3 and MySQL 8.0.
- The app version moves so existing installs run the new migration.

Closes #4909

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WilcoLouwerse WilcoLouwerse self-assigned this Nov 6, 2026
WilcoLouwerse and others added 4 commits November 6, 2026 15:59
…5879)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed on MariaDB

Enabling the app on MariaDB 11.4 failed with error 1064: Doctrine leaves
row_number unquoted there. Version1Date20260915050000 now creates source_row.
Version1Date20261106080000 renames the column on installs that already hold it,
with one quoted RENAME COLUMN, so their rows and the unique index stay. The
version moves with it, or occ upgrade would not read the new step.

The API is unchanged: rows are still answered under the key row.

Assisted-by: ClaudeCode:claude-opus-5-5
(cherry picked from commit 8f5838c)
Assisted-by: ClaudeCode:claude-opus-5-5
(cherry picked from commit cbc50fe)
…words on MariaDB and MySQL

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WilcoLouwerse WilcoLouwerse changed the title fix(db): rename the import-preview column row_number to row_no for MariaDB (beta) fix(import): import preview rows use source_row, row_number is reserved on MariaDB (beta) Nov 6, 2026
…ine quotes each word

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@WilcoLouwerse WilcoLouwerse left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verdict: APPROVE (Thorough · full)

Self-review, so it is posted as a comment (GitHub refuses an approval of your own PR). This is a faithful backport of #5879 to beta, with two tests that would catch the same class of bug next time. There are no blockers. One nit was fixed on the branch before posting, and one is handled in the PR description.

Connected issues

Issue Relation State Action
#4909 fixed on beta by this PR (on development by #5879) open ⚠️ close by hand once the beta release is verified: beta is not the default branch, so the merge will not close it
#4311 MySQL 8 install fails earlier (JSON default); outside this PR open none

🟢 Nits

  • f2: the description said Closes #4909. That keyword only acts on merges into main, the default branch; #5879 into development left #4909 open for the same reason. The description now says the issue is closed by hand.
  • f3, fixed in 1f079e7: the comment above ReservedColumnNamesTest::ALREADY_IN_USE said Doctrine has every listed word in both its MariaDB and MySQL keyword lists. groups is missing from the MariaDB list and offset from the MySQL 8 list. Neither is a live bug, because groups is not reserved on MariaDB 11.3 and offset is not reserved on MySQL 8.0 (per the fixtures). The comment now says where Doctrine quotes each word.

✅ Verified clean

  • Backport fidelity: these files are byte-identical to origin/development:

    • Version1Date20260915050000
    • Version1Date20261106120000
    • ImportPreviewRow
    • Version1Date20261106120000Test
    • ImportPreviewServiceTest

    The remaining mapper, service and controller-test differences are development-only drift (QueryPage, the *Interface DI types), not part of #5879. Both cherry-picks carry their -x trailers. The golden fixture does not exist on beta, so dropping it is correct.

  • No leftover of the reverted row_no variant anywhere in the tree. The remaining row_number / rowNumber hits belong to the migration packs and the import service, not to this table. The JSON key row is unchanged.

  • The rename SQL is valid on MariaDB 10.5.2+, MySQL 8, PostgreSQL and SQLite 3.25+. getTableName() / getColumnName() give backticks and *PREFIX*, and finishQuery turns those into " on PostgreSQL and SQLite. The unique index follows the rename on every engine.

  • Fresh installs take the schema-only path, which skips preSchemaChange. That is correct, because Version1Date20260915050000 now creates source_row. The class has no changeSchema, so SchemaReuseHygieneTest holds.

  • <version> 2.1.42-beta.20261106120000 is higher than 2.1.42-beta.20261102161558, and check-migration-version-bump passes.

  • The new tests:

    • ImportPreviewRowMapperMigratedTest fails on a row_number column and on an unquoted sort.
    • ReservedColumnNamesTest guards against an empty schema and against a stale allowance.
    • Both use the existing MigratedSqliteDatabase.

Gates: quality / Hydra Gates succeeded on 9b782c9, the reviewed head. On 1f079e7 (a comment-only change on top of it) CI was still running at the time of this verdict.
CI: on 9b782c9 everything was green except E2E and the Quality Report, which were still pending. That includes PHPUnit on PHP 8.3 and 8.4 × NC stable32–35 (29151 tests), phpcs, phpmd, psalm and phpstan.
Local: MariaDB 11.3 and PostgreSQL 16 rig scenarios (fresh install, upgrade from the failed state, hand-made tables with rows), as listed in the description.
Not run: no pre-push adversarial agent for 1f079e7: it changes three comment lines and no code.

Analysis: one Thorough agent. Of its three nits, one was refuted on verification: it read the sync as development → beta only, but beta → development sync PRs exist (#5398).

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 3b4f5c5

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ✅
psalm ✅
phpstan ✅
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
check-specs ✅
test-l10n ✅
test-l10n-parity ✅
format ✅
check-schema-l10n ✅
composer ✅ ✅ 165/165
npm ✅ ✅ 640/640
app:check-code ⏭️
info.xml ✅
REUSE ✅
lockfile sync ✅
PHPUnit ✅ 29134/29134 · 18 skipped (8 legs)
Newman ✅ 714/714
Playwright ❌ 249/327 · 5 skipped · 161 did not run
Hydra gates ✅

Quality workflow — 2026-11-06 17:54 UTC

Download the full PDF report from the workflow artifacts.

@WilcoLouwerse
WilcoLouwerse merged commit 2be0c2c into beta Nov 6, 2026
52 of 54 checks passed
@WilcoLouwerse
WilcoLouwerse deleted the hotfix/beta-4909-mariadb-row-number branch November 6, 2026 19:31
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.

2 participants