Addshore has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/92892


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
3 files changed, 18 insertions(+), 15 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseDatabase 
refs/changes/92/92892/1

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..20bfb40 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
+        *
+*@param string $tableName
+        *
+*@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

-- 
To view, visit https://gerrit.wikimedia.org/r/92892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I46aaa1abd7fc816849cdc4a6e1d442e50aa9ab9d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseDatabase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to