WordPress / WordPress/sqlite-database-integration

Honor PDO::ATTR_CASE and PDO::ATTR_ORACLE_NULLS without affecting internal queries

Open
#475 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

WP_MySQL_On_SQLite forwards numeric PDO constructor options and most setAttribute() calls to the underlying SQLite PDO connection. Setting PDO::ATTR_CASE or PDO::ATTR_ORACLE_NULLS therefore changes internal query results as well as caller-visible results.

For PDO::ATTR_CASE, constructing the driver with PDO::CASE_LOWER lowercases keys returned by internal INFORMATION_SCHEMA queries. Driver code expects canonical keys such as COLUMN_NAME, so a subsequent CREATE TABLE emits an undefined-key warning and fails.

PDO::ATTR_ORACLE_NULLS can silently corrupt schema metadata. With PDO::NULL_TO_STRING, even CREATE TABLE t (id INT PRIMARY KEY) creates the SQLite column with DEFAULT ''. With PDO::NULL_EMPTY_STRING, internal metadata fields become null and operations such as SHOW CREATE TABLE fail.

Proposed solution

Treat both attributes as caller-visible wrapper state, similarly to PDO::ATTR_ERRMODE:

  • Track the requested case and Oracle null modes in WP_MySQL_On_SQLite and expose them through setAttribute() and getAttribute().
  • Keep the underlying SQLite connection at PDO::CASE_NATURAL and PDO::NULL_NATURAL for internal queries.
  • Apply the requested modes only to caller-visible result statements, including SELECT, SHOW, DESCRIBE, and synthesized result sets.
  • For PDO::ATTR_CASE, scope the requested mode around preparing and executing result statements, then restore PDO::CASE_NATURAL in a finally block. PDO captures folded result-column names when a statement is executed.
  • For PDO::ATTR_ORACLE_NULLS, apply the requested null conversion in the result-statement layer. PDO SQLite consults the connection-level setting when rows are fetched, so temporarily changing it only during execution is insufficient and leaving it enabled would affect later internal queries.

Add coverage for constructor options and runtime attribute changes using PDO::CASE_LOWER, PDO::CASE_UPPER, PDO::NULL_TO_STRING, and PDO::NULL_EMPTY_STRING. Verify fetch modes, associative and object results, getColumnMeta(), DDL and schema reconstruction, SHOW CREATE TABLE, and behavior across the supported PHP versions.

This is a follow-up to #471.

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

Start in WP_MySQL_On_SQLite, focusing on PDO attribute handling and the result-statement layer. Add coverage for constructor options and runtime changes using PDO::CASE_LOWER, PDO::CASE_UPPER, PDO::NULL_TO_STRING, and PDO::NULL_EMPTY_STRING. Done means caller-visible SELECT, SHOW, DESCRIBE, and synthesized results honor the requested modes while internal queries, DDL, schema reconstruction, SHOW CREATE TABLE, fetch modes, object results, and getColumnMeta() remain correct across supported PHP versions.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.