Skip to content

Add DBR::Misc::DBI::Compat shim to restore DBD::mysql 4.036 string behavior#17

Merged
riccardo-perotti merged 2 commits into
masterfrom
perl-536-dbd-mysql-compat-shim
May 18, 2026
Merged

Add DBR::Misc::DBI::Compat shim to restore DBD::mysql 4.036 string behavior#17
riccardo-perotti merged 2 commits into
masterfrom
perl-536-dbd-mysql-compat-shim

Conversation

@riccardo-perotti

@riccardo-perotti riccardo-perotti commented May 11, 2026

Copy link
Copy Markdown

Summary

  • lib/DBR/Misc/DBI/Compat.pm (new file): DBI RootClass that overrides all fetch methods on MySQL statement handles to stringify every returned value, restoring the DBD::mysql 4.036 behavior where all numeric columns were returned as string scalars (SVp_POK).
  • lib/DBR/Config/Instance.pm (~3 lines): passes { RootClass => 'DBR::Misc::DBI::Compat' } to DBI->connect for MySQL connections only. MonetDB and SQLite connections are unaffected.

Background

DBD::mysql 4.050 is required for Debian Bookworm (libmariadb 3.x). It returns integer columns as IV scalars and float columns as NV scalars instead of strings. JSON::XS encodes these as bare numbers (42) rather than quoted strings ("42"), breaking any consumer that relies on string-encoded numerics.

Because all MySQL connections originate from the single DBI->connect call in _new_connection, this shim covers the entire codebase — both DBR ORM paths and raw $dbh callers — with no changes required in any service code.

This is a temporary migration bridge. It should be removed once all consumers have been audited and verified safe with bare-number JSON encoding.

Full diagnosis, audit findings, and decision rationale: perl-base-image-v2/DBD-mysql-numeric-types.md

Test plan

  • Run existing perl-DBR test suite against the new image (perl-base-image-v2:dev) to confirm no regressions
  • Run perl-modules-usage-snapshot DBD::mysql sidecar tests against the new image — all 12 previously failing tests should now pass
  • Verify a SOA endpoint returning numeric fields produces quoted strings in JSON responses (same as current production behavior)

Jira ticket

https://gudtech.atlassian.net/browse/ROP-9213

🤖 Generated with Claude Code

riccardo-perotti and others added 2 commits May 11, 2026 15:33
…havior

DBD::mysql 4.050 (required for Debian Bookworm / libmariadb 3.x) returns
numeric MySQL columns as IV/NV scalars instead of string scalars (SVp_POK).
This changes JSON::XS output from quoted strings ("42") to bare numbers (42),
breaking consumers that rely on string-encoded numerics.

DBR::Misc::DBI::Compat is a DBI RootClass that overrides all fetch methods on
MySQL statement handles to stringify every returned value, restoring 4.036
behavior transparently across all callers — both DBR ORM paths and raw $dbh
users (e.g. Dashboard.pm) — with no changes required in service code.

This is an intentional temporary migration bridge. It should be removed once
all consumers have been audited and verified safe with bare-number JSON encoding.

See: perl-base-image-v2/DBD-mysql-numeric-types.md (Option B)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CircleCI SSH key was no longer functional. Replaces .circleci/config.yml
with .github/workflows/build-and-test.yml using the standard perl:5.24
Docker Hub image; installs deps via cpanm, builds with make, runs make test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Fix CI: use actions/checkout@v3 for perl:5.24 (Debian Stretch) compatibility

actions/checkout@v4 uses Node 20 which requires glibc 2.27+; Debian Stretch
ships glibc 2.24. Downgrade to v3 (Node 16, requires glibc 2.17).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Fix CI: switch to perl:5.36 (Debian Bookworm) container

GitHub Actions now forces Node 20 for all actions, including checkout@v3.
Node 20 requires glibc 2.28+; perl:5.24 (Debian Stretch) ships glibc 2.24.

perl:5.36 (Debian Bookworm, glibc 2.36) resolves the incompatibility and
aligns CI with the migration target environment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Fix CI: run on ubuntu-latest without container

Drop the Docker container entirely. The perl:5.24 image (Debian Stretch,
glibc 2.24) is incompatible with Node 20 required by all current GitHub
Actions. Running directly on ubuntu-latest uses the system Perl on Ubuntu
22.04 and avoids the issue. Added sudo for apt-get (runner is non-root).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Fix CI: install cpanminus via apt before using cpanm

ubuntu-latest does not include cpanm pre-installed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Fix CI: run cpanm with sudo so deps install to system Perl paths

Without sudo, cpanm cannot write to system Perl directories and the
installs fail silently, leaving modules missing from @inc.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Fix CI: chown working directory back to runner after sudo cpanm

sudo cpanm creates MYMETA.json as root, causing 'Permission denied' when
the non-root build step tries to overwrite it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@riccardo-perotti riccardo-perotti force-pushed the perl-536-dbd-mysql-compat-shim branch from 164b709 to 375b750 Compare May 11, 2026 21:11
@riccardo-perotti riccardo-perotti merged commit 9057fdc into master May 18, 2026
1 check passed
@riccardo-perotti riccardo-perotti deleted the perl-536-dbd-mysql-compat-shim branch May 18, 2026 14:58
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.

1 participant