WordPress / WordPress/sqlite-database-integration
Match PDO MySQL lastInsertId() behavior in edge cases
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_INCREMENTcan 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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