diff --git a/framework/db/ActiveRecord.php b/framework/db/ActiveRecord.php index b9ac57edce..d90b22a708 100644 --- a/framework/db/ActiveRecord.php +++ b/framework/db/ActiveRecord.php @@ -291,12 +291,15 @@ class ActiveRecord extends BaseActiveRecord */ public static function getTableSchema() { - $schema = static::getDb()->getSchema()->getTableSchema(static::tableName()); - if ($schema !== null) { - return $schema; - } else { + $schema = static::getDb() + ->getSchema() + ->getTableSchema(static::tableName()); + + if ($schema === null) { throw new InvalidConfigException('The table does not exist: ' . static::tableName()); } + + return $schema; } /** diff --git a/framework/db/Schema.php b/framework/db/Schema.php index 985e229af4..d98a9c526d 100644 --- a/framework/db/Schema.php +++ b/framework/db/Schema.php @@ -104,7 +104,7 @@ abstract class Schema extends Object /** * Loads the metadata for the specified table. * @param string $name table name - * @return TableSchema DBMS-dependent table metadata, null if the table does not exist. + * @return null|TableSchema DBMS-dependent table metadata, null if the table does not exist. */ abstract protected function loadTableSchema($name); @@ -112,7 +112,7 @@ abstract class Schema extends Object * Obtains the metadata for the named table. * @param string $name table name. The table name may contain schema name if any. Do not quote the table name. * @param boolean $refresh whether to reload the table schema even if it is found in the cache. - * @return TableSchema table metadata. Null if the named table does not exist. + * @return null|TableSchema table metadata. Null if the named table does not exist. */ public function getTableSchema($name, $refresh = false) {