WordPress / WordPress/sqlite-database-integration

Decouple driver internals from PDO::ATTR_STRINGIFY_FETCHES

Open
#451 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
363
Forks
67
Avg merge
2d 15h
Merged PRs (30d)
7

Description

Problem

The MySQL-on-SQLite driver currently relies on PDO::ATTR_STRINGIFY_FETCHES being enabled for some of its internal metadata queries.

When stringification is disabled (the default for PDO SQLite), SQLite metadata values are returned as integers on current PHP versions. Several driver paths compare those values strictly against strings, so changing a public PDO fetch attribute can alter internal DDL and emulation behavior.

Known examples include:

  • detecting temporary information-schema tables with fetchColumn() === '1'
  • restoring PRAGMA foreign_keys only when its value is strictly '1'
  • interpreting NON_UNIQUE only when its value is strictly '0'
  • reconstructing columns and indexes by comparing notnull, pk, and unique metadata to string values

This was observed while simplifying the driver API in #449. With PDO::ATTR_STRINGIFY_FETCHES disabled, translation tests failed because unique indexes were recreated as non-unique and foreign-key state handling was skipped.

WordPress and the MySQL binary protocol adapter may still choose to enable stringified fetches for their outward compatibility. The driver's internal correctness should not depend on that caller-facing setting.

Expected behavior

  • Normalize or cast internal SQLite metadata independently of PDO::ATTR_STRINGIFY_FETCHES.
  • Produce identical DDL, index, foreign-key, and information-schema behavior whether stringified fetches are enabled or disabled.
  • Continue honoring PDO::ATTR_STRINGIFY_FETCHES for result values returned through the public PDO-compatible API.
  • Add coverage for both attribute states, including unique index reconstruction and foreign-key handling.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the MySQL-on-SQLite driver for the listed fetchColumn and metadata comparisons, then inspect the translation tests that exposed the failures. Exercise the relevant paths with PDO::ATTR_STRINGIFY_FETCHES enabled and disabled; done means identical DDL, index, foreign-key, and information-schema behavior while public result values still honor the attribute.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sqlite
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.