wiki.techinc.nl/tests/phpunit/unit/includes/libs/rdbms/SQLPlatformTestHelper.php
Tim Starling f3607d6512 Simplify addIdentifierQuotes and its inverse
* Instead of quoting any possible input as an identifier, validate the
  input and fail if it contains a special character. This allows us to
  simplify the implementation of the corresponding unquoting in
  SQLPlatform::extractTableNameComponents.
* Add getIdentifierQuoteChar(), and unify the implementations except
  for this one detail.
* addIdentifierQuotes() was/is not abstract. Remove the incorrect
  comment about this from DatabaseTest. I tried removing the stub from
  SQLPlatformTestHelper but there were 170 test failures, so it gets a
  TODO for now.

Change-Id: I711968b17b303bbb5efd2882bc676b695d25ef7f
2023-12-13 15:10:05 -08:00

62 lines
1.8 KiB
PHP

<?php
/**
* DO NOT use it in production.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\Tests\Unit\Libs\Rdbms;
use Wikimedia\Rdbms\Platform\SQLPlatform;
class SQLPlatformTestHelper extends SQLPlatform {
/**
* @var bool Value to return from unionSupportsOrderAndLimit()
*/
protected $unionSupportsOrderAndLimit = true;
/**
* TODO: remove
*
* This was previously a stub for an abstract method, but now this is the
* only override. But many tests depend on unquoted table names appearing
* in query strings.
*
* @param string $s
* @return string
*/
public function addIdentifierQuotes( $s ) {
return $s;
}
public function useIndexClause( $index ) {
return "FORCE INDEX (" . $this->indexName( $index ) . ")";
}
public function ignoreIndexClause( $index ) {
return "IGNORE INDEX (" . $this->indexName( $index ) . ")";
}
public function unionSupportsOrderAndLimit() {
return $this->unionSupportsOrderAndLimit;
}
public function setUnionSupportsOrderAndLimit( $v ) {
$this->unionSupportsOrderAndLimit = (bool)$v;
}
}