WordPress / WordPress/sqlite-database-integration

Match PDO MySQL lastInsertId() behavior in edge cases

Open
#474 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::lastInsertId() snapshots SQLite's last row ID, but SQLite and PDO MySQL differ in several cases:

  • A multi-row insert returns SQLite's last generated ID; PDO MySQL returns the first.
  • An insert into a table without AUTO_INCREMENT can expose a SQLite row ID; PDO MySQL returns "0".
  • A fully ignored insert can expose a stale or advanced SQLite ID; PDO MySQL returns "0".

The PDO coverage work in #471 handles initialization, operation resets, and isolation from internal SQLite writes, but not these differences.

Expected behavior

Derive the ID from the user-issued MySQL INSERT or REPLACE operation rather than directly exposing SQLite's connection-level last row ID.

Add coverage for single-row, multi-row, explicit-ID, non-auto-increment, ignored, replace, and duplicate-key-update cases.

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 with WP_MySQL_On_SQLite::lastInsertId() and the PDO coverage work referenced in #471. Add coverage for the listed INSERT and REPLACE cases, then verify the returned IDs match PDO MySQL behavior rather than SQLite's connection-level last row ID.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php, sqlite
Domain
databases
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.