Jeroen De Dauw has submitted this change and it was merged.
Change subject: rename Schema ReadException => ReadingException
......................................................................
rename Schema ReadException => ReadingException
Change-Id: I46aaa1abd7fc816849cdc4a6e1d442e50aa9ab9d
---
M src/MySQL/MySQLTableDefinitionReader.php
M src/SQLite/SQLiteTableDefinitionReader.php
R src/Schema/SchemaReadingException.php
M tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php
M tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php
5 files changed, 19 insertions(+), 16 deletions(-)
Approvals:
Jeroen De Dauw: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/MySQL/MySQLTableDefinitionReader.php
b/src/MySQL/MySQLTableDefinitionReader.php
index f231dce..a0e59f3 100644
--- a/src/MySQL/MySQLTableDefinitionReader.php
+++ b/src/MySQL/MySQLTableDefinitionReader.php
@@ -8,7 +8,7 @@
use Wikibase\Database\Schema\Definitions\FieldDefinition;
use Wikibase\Database\Schema\Definitions\IndexDefinition;
use Wikibase\Database\Schema\Definitions\TableDefinition;
-use Wikibase\Database\Schema\SchemaReadException;
+use Wikibase\Database\Schema\SchemaReadingException;
use Wikibase\Database\Schema\TableDefinitionReader;
use Wikibase\Database\TableNameFormatter;
@@ -33,12 +33,12 @@
*
* @param string $tableName
*
- * @throws SchemaReadException
+ * @throws SchemaReadingException
* @return TableDefinition
*/
public function readDefinition( $tableName ) {
if( !$this->queryInterface->tableExists( $tableName ) ) {
- throw new SchemaReadException( "Unknown table
{$tableName}" );
+ throw new SchemaReadingException( "Unknown table
{$tableName}" );
}
$fields = $this->getFields( $tableName );
diff --git a/src/SQLite/SQLiteTableDefinitionReader.php
b/src/SQLite/SQLiteTableDefinitionReader.php
index 6e2244d..5af3c0e 100644
--- a/src/SQLite/SQLiteTableDefinitionReader.php
+++ b/src/SQLite/SQLiteTableDefinitionReader.php
@@ -8,7 +8,7 @@
use Wikibase\Database\Schema\Definitions\FieldDefinition;
use Wikibase\Database\Schema\Definitions\IndexDefinition;
use Wikibase\Database\Schema\Definitions\TableDefinition;
-use Wikibase\Database\Schema\SchemaReadException;
+use Wikibase\Database\Schema\SchemaReadingException;
use Wikibase\Database\Schema\TableDefinitionReader;
/**
@@ -36,12 +36,12 @@
*
* @param string $tableName
*
- * @throws SchemaReadException
+ * @throws SchemaReadingException
* @return TableDefinition
*/
public function readDefinition( $tableName ) {
if( !$this->queryInterface->tableExists( $tableName ) ){
- throw new SchemaReadException( "Unknown table
{$tableName}" );
+ throw new SchemaReadingException( "Unknown table
{$tableName}" );
}
$fields = $this->getFields( $tableName );
@@ -53,14 +53,16 @@
/**
* Returns an array of all fields in the given table
+ *
* @param string $tableName
- * @throws SchemaReadException
+ *
+ * @throws SchemaReadingException
* @return FieldDefinition[]
*/
private function getFields( $tableName ) {
$results = $this->doCreateQuery( $tableName );
if( iterator_count( $results ) > 1 ){
- throw new SchemaReadException( "More than one set of
fields returned for {$tableName}" );
+ throw new SchemaReadingException( "More than one set of
fields returned for {$tableName}" );
}
$fields = array();
@@ -69,13 +71,13 @@
/** $createParts, 1 => tableName, 2 => fieldParts
(fields, keys, etc.) */
$matchedCreate = preg_match( '/CREATE TABLE ([^ ]+)
\(([^\)]+)\)/', $sql, $createParts );
if( $matchedCreate !== 1 ){
- throw new SchemaReadException( "Failed to match
CREATE TABLE regex with sql string: " . $sql );
+ throw new SchemaReadingException( "Failed to
match CREATE TABLE regex with sql string: " . $sql );
}
foreach( explode( ',', $createParts[2] ) as $fieldSql )
{
$matchedParts = preg_match( '/([^ ]+) ([^ ]+)(
DEFAULT ([^ ]+))?( ((NOT )?NULL))?( (PRIMARY KEY AUTOINCREMENT))?/', $fieldSql,
$fieldParts );
if( $matchedParts !== 1 ){
- throw new SchemaReadException( "Failed
to match CREATE TABLE \$fieldSql regex with sql string: " . $fieldSql . " -
parsed from : ". $sql );
+ throw new SchemaReadingException(
"Failed to match CREATE TABLE \$fieldSql regex with sql string: " . $fieldSql .
" - parsed from : ". $sql );
} else if( $fieldParts[0] !== 'PRIMARY KEY' ) {
$fields[] = $this->getField(
$fieldParts );
}
@@ -89,15 +91,16 @@
* @param array $fields
* @param string $tableName
* @param ResultIterator $results
- * @throws SchemaReadException
+ *
+ * @throws SchemaReadingException
*/
private function throwExceptionIfNoFields( $fields, $tableName,
$results ){
if( count( $fields ) === 0 ){
$message = "Failed to read any fields for table:
{$tableName} from sql: ";
foreach( $results as $result ){
- $message .= "\n" . $result->sql;
+ $message .= "\n'" . $result->sql . "'";
}
- throw new SchemaReadException( $message );
+ throw new SchemaReadingException( $message );
}
}
diff --git a/src/Schema/SchemaReadException.php
b/src/Schema/SchemaReadingException.php
similarity index 70%
rename from src/Schema/SchemaReadException.php
rename to src/Schema/SchemaReadingException.php
index 44a1fb1..1290b21 100644
--- a/src/Schema/SchemaReadException.php
+++ b/src/Schema/SchemaReadingException.php
@@ -7,6 +7,6 @@
* @licence GNU GPL v2+
* @author Adam Shorland
*/
-class SchemaReadException extends \Exception {
+class SchemaReadingException extends \Exception {
}
\ No newline at end of file
diff --git a/tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php
b/tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php
index f5e05e5..3c32455 100644
--- a/tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php
+++ b/tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php
@@ -52,7 +52,7 @@
}
public function testReadNonExistentTable(){
- $this->setExpectedException(
'Wikibase\Database\Schema\SchemaReadException' );
+ $this->setExpectedException(
'Wikibase\Database\Schema\SchemaReadingException' );
$reader = $this->newInstance( array(), false );
$reader->readDefinition( 'dbNametableName' );
}
diff --git a/tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php
b/tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php
index 73ed62f..c912a78 100644
--- a/tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php
+++ b/tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php
@@ -54,7 +54,7 @@
}
public function testReadNonExistentTable(){
- $this->setExpectedException(
'Wikibase\Database\Schema\SchemaReadException' );
+ $this->setExpectedException(
'Wikibase\Database\Schema\SchemaReadingException' );
$reader = $this->newInstance( array(), false );
$reader->readDefinition( 'fooBarImNotATable' );
}
--
To view, visit https://gerrit.wikimedia.org/r/92892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I46aaa1abd7fc816849cdc4a6e1d442e50aa9ab9d
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/WikibaseDatabase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits