Commit graph

4 commits

Author SHA1 Message Date
Umherirrender
770f905900 tests: Use namespaced IDatabase class
Change-Id: I7171ff26faee00d9eaabc33c2f3d91049ea0b40d
2022-05-28 00:09:55 +02:00
Aryeh Gregor
62e5146a13 GlobalIdGeneratorTest is not a unit test
It calls the Shell class, which uses MediaWikiServices. Why was this not
causing test failures on CI?

Change-Id: Id953c1425659ede158034988dd652b59a0e9811b
2022-04-24 15:49:43 +03:00
Tim Starling
a8d6499c17 Make IResultWrapper::seek() throw an exception
Make IResultWrapper inherit from SeekableIterator instead of Iterator.
As suggested by the interface documentation, throw an
OutOfBoundsException when the seek is out of bounds, instead of failing
in subtle ways.

Change-Id: I60427bc9057677254f1b06177ec525f1ae917721
2021-08-02 11:37:45 +10:00
Tim Starling
bc76602493 DBMS-specific ResultWrapper subclasses
Cleanup after the switch of Database::query() to return ResultWrapper
instead of resource.

* Soft-deprecate the IResultWrapper accessors in IDatabase.
* Move relevant DBMS-specific functionality to ResultWrapper subclasses.
  The deprecated methods in IResultWrapper become short and simple.
  ResultWrapper is now abstract (b/c break).
* Move the implementation of fieldName(), numFields() and one of the
  fieldInfo() implementations to the ResultWrapper subclass in order to
  avoid ResultWrapper::unwrap() calls.
* Make Database::doQuery() return a ResultWrapper subclass instead of
  underlying result data, so that the Database parent class does not
  need to be aware of wrapper construction.
* Hard-deprecate ResultWrapper::unwrap(),
  DatabaseMysqlBase::fieldType(), DatabasePostgres::fieldType().
* Fix the inefficient seeking method in SQLite.
* Make FakeResultWrapper extend ResultWrapper with an implementation
  similar to the SQLite one. This is possible because ResultWrapper does
  not depend on IDatabase anymore.
* Resolve fixme in DatabasePostgres: from studying the source,
  neither pg_fetch_object() nor pg_num_rows() can set an error
  retrievable with pg_last_error(). Removed unnecessary warning
  suppression.
* ResultWrapperTest didn't make sense as a unit test anymore, so I
  adapted it as an integration test against the current DBMS.

This change also means that ResultWrapper::key() always gives the
correct offset, even if Iterator methods are not being used.

Bug: T286694
Change-Id: I935835316c0bd7d3d061bd8fde9c9ce99ce756ec
2021-07-21 06:54:26 -07:00