wiki.techinc.nl/tests/phpunit/includes/db
Aaron Schulz 924d1f0374 rdbms: make IDatabase::insertId() less fragile and more consistent
Track the insert ID value in Database, similar to the affected rows.
This makes it possible for subclasses to stash or override the value,
which is useful when emulating a write operation using multiple queries.
This includes the case of internal use of atomic sections, where the
COMMIT/RELEASE can reset the last_insert_id tracked in the PECL driver
itself.

Use separate methods and fields for "last query statement" information
and "last query method" information.

Make insertId() for SQLite and Postgres better match MySQL:
* Return 0 if the last query statement did not change any rows.
  This helps protect against callers that fail to check affectedRows().
* Make it return the existing ROWID/SERIAL column when upsert() updates
  an existing row. This adds a new getInsertIdColumnForUpsert() helper
  function.

Directly use query() in doReplace() and doInsertSelectGeneric() to make
the affected row/ID logic easier to follow.

Improve insertId() and affectedRows() documentation.

Add more integration tests of row insertion methods.

Bug: T314100
Change-Id: I7d43a2e52260e66acb713554bb883f5f4a14d010
2023-05-26 19:01:45 -07:00
..
DatabaseTestHelper.php rdbms: make IDatabase::insertId() less fragile and more consistent 2023-05-26 19:01:45 -07:00
LBFactoryTest.php rdbms: simplify affectedRows() by using the QueryStatus result 2023-04-29 17:07:57 +00:00
LoadBalancerTest.php rdbms: make IDatabase::insertId() less fragile and more consistent 2023-05-26 19:01:45 -07:00