Rename classes to remove the redundant Database prefix and move query exceptions into the query namespace.
parent
0879ffd974
commit
05a4376ff4
|
@ -43,7 +43,7 @@ abstract class Connection extends PDO {
|
|||
/**
|
||||
* The current database logging object for this connection.
|
||||
*
|
||||
* @var DatabaseLog
|
||||
* @var Log
|
||||
*/
|
||||
protected $logger = NULL;
|
||||
|
||||
|
@ -70,7 +70,7 @@ abstract class Connection extends PDO {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $statementClass = '\\Drupal\\Database\\DatabaseStatementBase';
|
||||
protected $statementClass = '\\Drupal\\Database\\StatementBase';
|
||||
|
||||
/**
|
||||
* Whether this database connection supports transactions.
|
||||
|
@ -357,7 +357,7 @@ abstract class Connection extends PDO {
|
|||
* @param $logger
|
||||
* The logging object we want to use.
|
||||
*/
|
||||
public function setLogger(DatabaseLog $logger) {
|
||||
public function setLogger(Log $logger) {
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
@ -714,7 +714,7 @@ abstract class Connection extends PDO {
|
|||
*/
|
||||
public function schema() {
|
||||
if (empty($this->schema)) {
|
||||
$class = $this->getDriverClass('DatabaseSchema');
|
||||
$class = $this->getDriverClass('Schema');
|
||||
if (class_exists($class)) {
|
||||
$this->schema = new $class($this);
|
||||
}
|
||||
|
@ -833,7 +833,7 @@ abstract class Connection extends PDO {
|
|||
* The name of the savepoint. The default, 'drupal_transaction', will roll
|
||||
* the entire transaction back.
|
||||
*
|
||||
* @throws DatabaseTransactionNoActiveException
|
||||
* @throws TransactionNoActiveException
|
||||
*
|
||||
* @see DatabaseTransaction::rollback()
|
||||
*/
|
||||
|
@ -842,12 +842,12 @@ abstract class Connection extends PDO {
|
|||
return;
|
||||
}
|
||||
if (!$this->inTransaction()) {
|
||||
throw new DatabaseTransactionNoActiveException();
|
||||
throw new TransactionNoActiveException();
|
||||
}
|
||||
// A previous rollback to an earlier savepoint may mean that the savepoint
|
||||
// in question has already been accidentally committed.
|
||||
if (!isset($this->transactionLayers[$savepoint_name])) {
|
||||
throw new DatabaseTransactionNoActiveException();
|
||||
throw new TransactionNoActiveException();
|
||||
}
|
||||
|
||||
// We need to find the point we're rolling back to, all other savepoints
|
||||
|
@ -865,7 +865,7 @@ abstract class Connection extends PDO {
|
|||
$this->query('ROLLBACK TO SAVEPOINT ' . $savepoint);
|
||||
$this->popCommittableTransactions();
|
||||
if ($rolled_back_other_active_savepoints) {
|
||||
throw new DatabaseTransactionOutOfOrderException();
|
||||
throw new TransactionOutOfOrderException();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -875,7 +875,7 @@ abstract class Connection extends PDO {
|
|||
}
|
||||
parent::rollBack();
|
||||
if ($rolled_back_other_active_savepoints) {
|
||||
throw new DatabaseTransactionOutOfOrderException();
|
||||
throw new TransactionOutOfOrderException();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -884,7 +884,7 @@ abstract class Connection extends PDO {
|
|||
*
|
||||
* If no transaction is already active, we begin a new transaction.
|
||||
*
|
||||
* @throws DatabaseTransactionNameNonUniqueException
|
||||
* @throws TransactionNameNonUniqueException
|
||||
*
|
||||
* @see DatabaseTransaction
|
||||
*/
|
||||
|
@ -893,7 +893,7 @@ abstract class Connection extends PDO {
|
|||
return;
|
||||
}
|
||||
if (isset($this->transactionLayers[$name])) {
|
||||
throw new DatabaseTransactionNameNonUniqueException($name . " is already in use.");
|
||||
throw new TransactionNameNonUniqueException($name . " is already in use.");
|
||||
}
|
||||
// If we're already in a transaction then we want to create a savepoint
|
||||
// rather than try to create another transaction.
|
||||
|
@ -916,8 +916,8 @@ abstract class Connection extends PDO {
|
|||
* @param $name
|
||||
* The name of the savepoint
|
||||
*
|
||||
* @throws DatabaseTransactionNoActiveException
|
||||
* @throws DatabaseTransactionCommitFailedException
|
||||
* @throws TransactionNoActiveException
|
||||
* @throws TransactionCommitFailedException
|
||||
*
|
||||
* @see DatabaseTransaction
|
||||
*/
|
||||
|
@ -953,7 +953,7 @@ abstract class Connection extends PDO {
|
|||
unset($this->transactionLayers[$name]);
|
||||
if (empty($this->transactionLayers)) {
|
||||
if (!parent::commit()) {
|
||||
throw new DatabaseTransactionCommitFailedException();
|
||||
throw new TransactionCommitFailedException();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1094,12 +1094,12 @@ abstract class Connection extends PDO {
|
|||
* A direct commit bypasses all of the safety checks we've built on top of
|
||||
* PDO's transaction routines.
|
||||
*
|
||||
* @throws DatabaseTransactionExplicitCommitNotAllowedException
|
||||
* @throws TransactionExplicitCommitNotAllowedException
|
||||
*
|
||||
* @see DatabaseTransaction
|
||||
*/
|
||||
public function commit() {
|
||||
throw new DatabaseTransactionExplicitCommitNotAllowedException();
|
||||
throw new TransactionExplicitCommitNotAllowedException();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown if an undefined database connection is requested.
|
||||
*/
|
||||
class DatabaseConnectionNotDefinedException extends Exception {}
|
||||
class ConnectionNotDefinedException extends RuntimeException {}
|
|
@ -90,11 +90,11 @@ abstract class Database {
|
|||
* methods than the few exposed through the Database class, so in some
|
||||
* cases it may be desirable to access it directly.
|
||||
*
|
||||
* @see DatabaseLog
|
||||
* @see Log
|
||||
*/
|
||||
final public static function startLog($logging_key, $key = 'default') {
|
||||
if (empty(self::$logs[$key])) {
|
||||
self::$logs[$key] = new DatabaseLog($key);
|
||||
self::$logs[$key] = new Log($key);
|
||||
|
||||
// Every target already active for this connection key needs to have the
|
||||
// logging object associated with it.
|
||||
|
@ -125,7 +125,7 @@ abstract class Database {
|
|||
* @return array
|
||||
* The query log for the specified logging key and connection.
|
||||
*
|
||||
* @see DatabaseLog
|
||||
* @see Log
|
||||
*/
|
||||
final public static function getLog($logging_key, $key = 'default') {
|
||||
if (empty(self::$logs[$key])) {
|
||||
|
@ -351,8 +351,8 @@ abstract class Database {
|
|||
* @param $target
|
||||
* The database target to open.
|
||||
*
|
||||
* @throws DatabaseConnectionNotDefinedException
|
||||
* @throws DatabaseDriverNotSpecifiedException
|
||||
* @throws ConnectionNotDefinedException
|
||||
* @throws DriverNotSpecifiedException
|
||||
*/
|
||||
final protected static function openConnection($key, $target) {
|
||||
if (empty(self::$databaseInfo)) {
|
||||
|
@ -362,11 +362,11 @@ abstract class Database {
|
|||
// If the requested database does not exist then it is an unrecoverable
|
||||
// error.
|
||||
if (!isset(self::$databaseInfo[$key])) {
|
||||
throw new DatabaseConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
|
||||
throw new ConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
|
||||
}
|
||||
|
||||
if (!$driver = self::$databaseInfo[$key][$target]['driver']) {
|
||||
throw new DatabaseDriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
|
||||
throw new DriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
|
||||
}
|
||||
|
||||
// We cannot rely on the registry yet, because the registry requires an
|
||||
|
|
|
@ -169,7 +169,7 @@ class Connection extends DatabaseConnection {
|
|||
unset($this->transactionLayers[$name]);
|
||||
if (empty($this->transactionLayers)) {
|
||||
if (!PDO::commit()) {
|
||||
throw new DatabaseTransactionCommitFailedException();
|
||||
throw new TransactionCommitFailedException();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -4,9 +4,9 @@ namespace Drupal\Database\Driver\mysql;
|
|||
|
||||
use Drupal\Database\Database;
|
||||
use Drupal\Database\Query\DatabaseCondition;
|
||||
use Drupal\Database\DatabaseSchemaObjectExistsException;
|
||||
use Drupal\Database\DatabaseSchemaObjectDoesNotExistException;
|
||||
use Drupal\Database\DatabaseSchema as DatabaseDatabaseSchema;
|
||||
use Drupal\Database\SchemaObjectExistsException;
|
||||
use Drupal\Database\SchemaObjectDoesNotExistException;
|
||||
use Drupal\Database\Schema as DatabaseSchema;
|
||||
|
||||
use Exception;
|
||||
|
||||
|
@ -15,7 +15,7 @@ use Exception;
|
|||
* @{
|
||||
*/
|
||||
|
||||
class DatabaseSchema extends DatabaseDatabaseSchema {
|
||||
class Schema extends DatabaseSchema {
|
||||
|
||||
/**
|
||||
* Maximum length of a table comment in MySQL.
|
||||
|
@ -300,10 +300,10 @@ class DatabaseSchema extends DatabaseDatabaseSchema {
|
|||
|
||||
public function renameTable($table, $new_name) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
}
|
||||
if ($this->tableExists($new_name)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
throw new SchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
}
|
||||
|
||||
$info = $this->getPrefixInfo($new_name);
|
||||
|
@ -321,10 +321,10 @@ class DatabaseSchema extends DatabaseDatabaseSchema {
|
|||
|
||||
public function addField($table, $field, $spec, $keys_new = array()) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
|
||||
}
|
||||
if ($this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
|
||||
}
|
||||
|
||||
$fixnull = FALSE;
|
||||
|
@ -360,7 +360,7 @@ class DatabaseSchema extends DatabaseDatabaseSchema {
|
|||
|
||||
public function fieldSetDefault($table, $field, $default) {
|
||||
if (!$this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
}
|
||||
|
||||
if (!isset($default)) {
|
||||
|
@ -375,7 +375,7 @@ class DatabaseSchema extends DatabaseDatabaseSchema {
|
|||
|
||||
public function fieldSetNoDefault($table, $field) {
|
||||
if (!$this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
}
|
||||
|
||||
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT');
|
||||
|
@ -390,10 +390,10 @@ class DatabaseSchema extends DatabaseDatabaseSchema {
|
|||
|
||||
public function addPrimaryKey($table, $fields) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
|
||||
}
|
||||
if ($this->indexExists($table, 'PRIMARY')) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
|
||||
}
|
||||
|
||||
$this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')');
|
||||
|
@ -410,10 +410,10 @@ class DatabaseSchema extends DatabaseDatabaseSchema {
|
|||
|
||||
public function addUniqueKey($table, $name, $fields) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
if ($this->indexExists($table, $name)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
|
||||
$this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')');
|
||||
|
@ -430,10 +430,10 @@ class DatabaseSchema extends DatabaseDatabaseSchema {
|
|||
|
||||
public function addIndex($table, $name, $fields) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
if ($this->indexExists($table, $name)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
|
||||
$this->connection->query('ALTER TABLE {' . $table . '} ADD INDEX `' . $name . '` (' . $this->createKeySql($fields) . ')');
|
||||
|
@ -450,10 +450,10 @@ class DatabaseSchema extends DatabaseDatabaseSchema {
|
|||
|
||||
public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
|
||||
if (!$this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
|
||||
}
|
||||
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
|
||||
throw new SchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
|
||||
}
|
||||
|
||||
$sql = 'ALTER TABLE {' . $table . '} CHANGE `' . $field . '` ' . $this->createFieldSql($field_new, $this->processField($spec));
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown if no driver is specified for a database connection.
|
||||
*/
|
||||
class DatabaseDriverNotSpecifiedException extends Exception {}
|
||||
class DriverNotSpecifiedException extends RuntimeException {}
|
|
@ -13,7 +13,7 @@ namespace Drupal\Database;
|
|||
* Every connection has one and only one logging object on it for all targets
|
||||
* and logging keys.
|
||||
*/
|
||||
class DatabaseLog {
|
||||
class Log {
|
||||
|
||||
/**
|
||||
* Cache of logged queries. This will only be used if the query logger is enabled.
|
||||
|
@ -109,7 +109,7 @@ class DatabaseLog {
|
|||
* @param $time
|
||||
* The time in milliseconds the query took to execute.
|
||||
*/
|
||||
public function log(DatabaseStatementInterface $statement, $args, $time) {
|
||||
public function log(StatementInterface $statement, $args, $time) {
|
||||
foreach (array_keys($this->queryLog) as $key) {
|
||||
$this->queryLog[$key][] = array(
|
||||
'query' => $statement->getQueryString(),
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Database;
|
||||
namespace Drupal\Database\Query;
|
||||
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown if an insert query specifies a field twice.
|
||||
|
@ -10,4 +10,4 @@ use Exception;
|
|||
* It is not allowed to specify a field as default and insert field, this
|
||||
* exception is thrown if that is the case.
|
||||
*/
|
||||
class FieldsOverlapException extends Exception {}
|
||||
class FieldsOverlapException extends RuntimeException {}
|
|
@ -3,8 +3,6 @@
|
|||
namespace Drupal\Database\Query;
|
||||
|
||||
use Drupal\Database\Database;
|
||||
use Drupal\Database\NoFieldsException;
|
||||
use Drupal\Database\FieldsOverlapException;
|
||||
|
||||
/**
|
||||
* General class for an abstracted INSERT query.
|
||||
|
|
|
@ -10,4 +10,4 @@ use Exception;
|
|||
* There are many ways that a merge query could be malformed. They should all
|
||||
* throw this exception and set an appropriately descriptive message.
|
||||
*/
|
||||
class InvalidMergeQueryException extends Exception {}
|
||||
class InvalidMergeQueryException extends RuntimeException {}
|
|
@ -4,7 +4,6 @@ namespace Drupal\Database\Query;
|
|||
|
||||
use Drupal\Database\Database;
|
||||
use Drupal\Database\Connection;
|
||||
use Drupal\Database\InvalidMergeQueryException;
|
||||
|
||||
use Exception;
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ use Drupal\Database\Query\PlaceholderInterface;
|
|||
* @see drupal_install_schema()
|
||||
*/
|
||||
|
||||
abstract class DatabaseSchema implements PlaceholderInterface {
|
||||
abstract class Schema implements PlaceholderInterface {
|
||||
|
||||
protected $connection;
|
||||
|
||||
|
@ -649,7 +649,7 @@ abstract class DatabaseSchema implements PlaceholderInterface {
|
|||
*/
|
||||
public function createTable($name, $table) {
|
||||
if ($this->tableExists($name)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t('Table %name already exists.', array('%name' => $name)));
|
||||
throw new SchemaObjectExistsException(t('Table %name already exists.', array('%name' => $name)));
|
||||
}
|
||||
$statements = $this->createTableSql($name, $table);
|
||||
foreach ($statements as $statement) {
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Base exception for Schema-related errors.
|
||||
*/
|
||||
class SchemaException extends RuntimeException {}
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Exception thrown if an object being modified doesn't exist yet.
|
||||
*
|
||||
|
@ -11,4 +9,4 @@ use Exception;
|
|||
* modify a database table, field, or index that does not currently exist in
|
||||
* the database schema.
|
||||
*/
|
||||
class DatabaseSchemaObjectDoesNotExistException extends Exception {}
|
||||
class SchemaObjectDoesNotExistException extends SchemaException {}
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Exception thrown if an object being created already exists.
|
||||
*
|
||||
|
@ -11,4 +9,4 @@ use Exception;
|
|||
* create a new database table, field, or index that already exists in the
|
||||
* database schema.
|
||||
*/
|
||||
class DatabaseSchemaObjectExistsException extends Exception {}
|
||||
class SchemaObjectExistsException extends SchemaException {}
|
|
@ -16,7 +16,7 @@ use PDOStatement;
|
|||
*
|
||||
* @see http://us.php.net/pdostatement
|
||||
*/
|
||||
class DatabaseStatementBase extends PDOStatement implements DatabaseStatementInterface {
|
||||
class StatementBase extends PDOStatement implements StatementInterface {
|
||||
|
||||
/**
|
||||
* Reference to the database connection object for this statement.
|
|
@ -15,7 +15,7 @@ use Iterator;
|
|||
*
|
||||
* @see SearchQuery
|
||||
*/
|
||||
class DatabaseStatementEmpty implements Iterator, DatabaseStatementInterface {
|
||||
class StatementEmpty implements Iterator, StatementInterface {
|
||||
|
||||
public function execute($args = array(), $options = array()) {
|
||||
return FALSE;
|
|
@ -23,7 +23,7 @@ use Traversable;
|
|||
* class DatabaseStatement_oracle implements Iterator, DatabaseStatementInterface {}
|
||||
* @endcode
|
||||
*/
|
||||
interface DatabaseStatementInterface extends Traversable {
|
||||
interface StatementInterface extends Traversable {
|
||||
|
||||
/**
|
||||
* Executes a prepared statement
|
|
@ -13,7 +13,7 @@ use PDOException;
|
|||
* This class behaves very similar to a PDOStatement but as it always fetches
|
||||
* every row it is possible to manipulate those results.
|
||||
*/
|
||||
class DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface {
|
||||
class StatementPrefetch implements Iterator, StatementInterface {
|
||||
|
||||
/**
|
||||
* The query string.
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Exception thrown when a commit() function fails.
|
||||
*/
|
||||
class DatabaseTransactionCommitFailedException extends Exception { }
|
||||
class TransactionCommitFailedException extends TransactionException { }
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown by an error in a database transaction.
|
||||
*/
|
||||
class TransactionException extends RuntimeException { }
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Exception to deny attempts to explicitly manage transactions.
|
||||
*
|
||||
* This exception will be thrown when the PDO connection commit() is called.
|
||||
* Code should never call this method directly.
|
||||
*/
|
||||
class DatabaseTransactionExplicitCommitNotAllowedException extends Exception { }
|
||||
class TransactionExplicitCommitNotAllowedException extends TransactionException { }
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Exception thrown when a savepoint or transaction name occurs twice.
|
||||
*/
|
||||
class DatabaseTransactionNameNonUniqueException extends Exception { }
|
||||
class TransactionNameNonUniqueException extends TransactionException { }
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Exception for when popTransaction() is called with no active transaction.
|
||||
*/
|
||||
class DatabaseTransactionNoActiveException extends Exception { }
|
||||
class TransactionNoActiveException extends TransactionException { }
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace Drupal\Database;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Exception thrown when a rollback() resulted in other active transactions being rolled-back.
|
||||
*/
|
||||
class DatabaseTransactionOutOfOrderException extends Exception { }
|
||||
class TransactionOutOfOrderException extends TransactionException { }
|
|
@ -10,7 +10,7 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
class DatabaseSchema_pgsql extends DatabaseSchema {
|
||||
class DatabaseSchema_pgsql extends Schema {
|
||||
|
||||
/**
|
||||
* A cache of information about blob columns and sequences of tables.
|
||||
|
@ -314,10 +314,10 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
|
|||
|
||||
function renameTable($table, $new_name) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
}
|
||||
if ($this->tableExists($new_name)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
throw new SchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
}
|
||||
|
||||
// Get the schema and tablename for the old table.
|
||||
|
@ -351,10 +351,10 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
|
|||
|
||||
public function addField($table, $field, $spec, $new_keys = array()) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
|
||||
}
|
||||
if ($this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
|
||||
}
|
||||
|
||||
$fixnull = FALSE;
|
||||
|
@ -393,7 +393,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
|
|||
|
||||
public function fieldSetDefault($table, $field, $default) {
|
||||
if (!$this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
}
|
||||
|
||||
if (!isset($default)) {
|
||||
|
@ -408,7 +408,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
|
|||
|
||||
public function fieldSetNoDefault($table, $field) {
|
||||
if (!$this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
}
|
||||
|
||||
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" DROP DEFAULT');
|
||||
|
@ -435,10 +435,10 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
|
|||
|
||||
public function addPrimaryKey($table, $fields) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
|
||||
}
|
||||
if ($this->constraintExists($table, 'pkey')) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
|
||||
}
|
||||
|
||||
$this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . implode(',', $fields) . ')');
|
||||
|
@ -455,10 +455,10 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
|
|||
|
||||
function addUniqueKey($table, $name, $fields) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
if ($this->constraintExists($table, $name . '_key')) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
|
||||
$this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT "' . $this->prefixNonTable($table, $name, 'key') . '" UNIQUE (' . implode(',', $fields) . ')');
|
||||
|
@ -475,10 +475,10 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
|
|||
|
||||
public function addIndex($table, $name, $fields) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
if ($this->indexExists($table, $name)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
|
||||
$this->connection->query($this->_createIndexSql($table, $name, $fields));
|
||||
|
@ -495,10 +495,10 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
|
|||
|
||||
public function changeField($table, $field, $field_new, $spec, $new_keys = array()) {
|
||||
if (!$this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
|
||||
}
|
||||
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
|
||||
throw new SchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
|
||||
}
|
||||
|
||||
$spec = $this->processField($spec);
|
||||
|
|
|
@ -37,7 +37,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
|
|||
/**
|
||||
* All databases attached to the current database. This is used to allow
|
||||
* prefixes to be safely handled without locking the table
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attachedDatabases = array();
|
||||
|
@ -46,10 +46,10 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
|
|||
* Whether or not a table has been dropped this request: the destructor will
|
||||
* only try to get rid of unnecessary databases if there is potential of them
|
||||
* being empty.
|
||||
*
|
||||
*
|
||||
* This variable is set to public because DatabaseSchema_sqlite needs to
|
||||
* access it. However, it should not be manually set.
|
||||
*
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
var $tableDropped = FALSE;
|
||||
|
@ -304,7 +304,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
|
|||
}
|
||||
|
||||
if (!$this->inTransaction()) {
|
||||
throw new DatabaseTransactionNoActiveException();
|
||||
throw new TransactionNoActiveException();
|
||||
}
|
||||
// A previous rollback to an earlier savepoint may mean that the savepoint
|
||||
// in question has already been rolled back.
|
||||
|
@ -340,7 +340,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
|
|||
return;
|
||||
}
|
||||
if (isset($this->transactionLayers[$name])) {
|
||||
throw new DatabaseTransactionNameNonUniqueException($name . " is already in use.");
|
||||
throw new TransactionNameNonUniqueException($name . " is already in use.");
|
||||
}
|
||||
if (!$this->inTransaction()) {
|
||||
PDO::beginTransaction();
|
||||
|
@ -356,7 +356,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
|
|||
return;
|
||||
}
|
||||
if (!$this->inTransaction()) {
|
||||
throw new DatabaseTransactionNoActiveException();
|
||||
throw new TransactionNoActiveException();
|
||||
}
|
||||
|
||||
// Commit everything since SAVEPOINT $name.
|
||||
|
@ -371,7 +371,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
|
|||
PDO::rollBack();
|
||||
}
|
||||
elseif (!PDO::commit()) {
|
||||
throw new DatabaseTransactionCommitFailedException();
|
||||
throw new TransactionCommitFailedException();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -390,7 +390,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
|
|||
*
|
||||
* @see DatabaseConnection_sqlite::PDOPrepare()
|
||||
*/
|
||||
class DatabaseStatement_sqlite extends DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface {
|
||||
class DatabaseStatement_sqlite extends StatementPrefetch implements Iterator, StatementInterface {
|
||||
|
||||
/**
|
||||
* SQLite specific implementation of getStatement().
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
class DatabaseSchema_sqlite extends DatabaseSchema {
|
||||
class DatabaseSchema_sqlite extends Schema {
|
||||
|
||||
/**
|
||||
* Override DatabaseSchema::$defaultSchema
|
||||
|
@ -232,10 +232,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
|
|||
|
||||
public function renameTable($table, $new_name) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
}
|
||||
if ($this->tableExists($new_name)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
throw new SchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
|
||||
}
|
||||
|
||||
$schema = $this->introspectSchema($table);
|
||||
|
@ -278,10 +278,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
|
|||
|
||||
public function addField($table, $field, $specification, $keys_new = array()) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
|
||||
}
|
||||
if ($this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
|
||||
}
|
||||
|
||||
// SQLite doesn't have a full-featured ALTER TABLE statement. It only
|
||||
|
@ -494,10 +494,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
|
|||
|
||||
public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
|
||||
if (!$this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
|
||||
}
|
||||
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
|
||||
throw new SchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
|
||||
}
|
||||
|
||||
$old_schema = $this->introspectSchema($table);
|
||||
|
@ -559,10 +559,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
|
|||
|
||||
public function addIndex($table, $name, $fields) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
if ($this->indexExists($table, $name)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
|
||||
$schema['indexes'][$name] = $fields;
|
||||
|
@ -591,10 +591,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
|
|||
|
||||
public function addUniqueKey($table, $name, $fields) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
if ($this->indexExists($table, $name)) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
|
||||
}
|
||||
|
||||
$schema['unique keys'][$name] = $fields;
|
||||
|
@ -617,14 +617,14 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
|
|||
|
||||
public function addPrimaryKey($table, $fields) {
|
||||
if (!$this->tableExists($table)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
|
||||
}
|
||||
|
||||
$old_schema = $this->introspectSchema($table);
|
||||
$new_schema = $old_schema;
|
||||
|
||||
if (!empty($new_schema['primary key'])) {
|
||||
throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
|
||||
throw new SchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
|
||||
}
|
||||
|
||||
$new_schema['primary key'] = $fields;
|
||||
|
@ -646,7 +646,7 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
|
|||
|
||||
public function fieldSetDefault($table, $field, $default) {
|
||||
if (!$this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
}
|
||||
|
||||
$old_schema = $this->introspectSchema($table);
|
||||
|
@ -658,7 +658,7 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
|
|||
|
||||
public function fieldSetNoDefault($table, $field) {
|
||||
if (!$this->fieldExists($table, $field)) {
|
||||
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
|
||||
}
|
||||
|
||||
$old_schema = $this->introspectSchema($table);
|
||||
|
|
|
@ -436,7 +436,7 @@ class SearchQuery extends SelectExtender {
|
|||
$this->executeFirstPass();
|
||||
}
|
||||
if (!$this->normalize) {
|
||||
return new DatabaseStatementEmpty();
|
||||
return new StatementEmpty();
|
||||
}
|
||||
|
||||
// Add conditions to query.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Drupal\Database\Database;
|
||||
use Drupal\Database\DatabaseConnectionNotDefinedException;
|
||||
use Drupal\Database\ConnectionNotDefinedException;
|
||||
|
||||
/**
|
||||
* Global variable that holds information about the tests being run.
|
||||
|
@ -155,7 +155,7 @@ abstract class DrupalTestCase {
|
|||
try {
|
||||
$connection = Database::getConnection('default', 'simpletest_original_default');
|
||||
}
|
||||
catch (DatabaseConnectionNotDefinedException $e) {
|
||||
catch (ConnectionNotDefinedException $e) {
|
||||
// If the test was not set up, the simpletest_original_default
|
||||
// connection does not exist.
|
||||
$connection = Database::getConnection('default', 'default');
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
|
||||
use Drupal\Database\Database;
|
||||
use Drupal\Database\DatabaseStatementEmpty;
|
||||
use Drupal\Database\DatabaseStatementInterface;
|
||||
use Drupal\Database\NoFieldsException;
|
||||
use Drupal\Database\InvalidMergeQueryException;
|
||||
use Drupal\Database\StatementEmpty;
|
||||
use Drupal\Database\StatementInterface;
|
||||
use Drupal\Database\TransactionOutOfOrderException;
|
||||
use Drupal\Database\Query\Merge;
|
||||
use Drupal\Database\Query\InvalidMergeQueryException;
|
||||
use Drupal\Database\Query\NoFieldsException;
|
||||
|
||||
/**
|
||||
* Dummy class for fetching into a class.
|
||||
|
@ -309,7 +310,7 @@ class DatabaseFetchTestCase extends DatabaseTestCase {
|
|||
function testQueryFetchDefault() {
|
||||
$records = array();
|
||||
$result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25));
|
||||
$this->assertTrue($result instanceof DatabaseStatementInterface, t('Result set is a Drupal statement object.'));
|
||||
$this->assertTrue($result instanceof StatementInterface, t('Result set is a Drupal statement object.'));
|
||||
foreach ($result as $record) {
|
||||
$records[] = $record;
|
||||
$this->assertTrue(is_object($record), t('Record is an object.'));
|
||||
|
@ -3536,7 +3537,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
|
|||
// "ROLLBACK" fails silently in MySQL if there is no transaction active.
|
||||
// $this->fail(t('Rolling back a transaction containing DDL should fail.'));
|
||||
}
|
||||
catch (DatabaseTransactionNoActiveException $e) {
|
||||
catch (TransactionNoActiveException $e) {
|
||||
$this->pass(t('Rolling back a transaction containing DDL should fail.'));
|
||||
}
|
||||
$this->assertRowPresent('row');
|
||||
|
@ -3704,7 +3705,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
|
|||
unset($transaction);
|
||||
$this->fail(t('Rolling back the outer transaction while the inner transaction is active resulted in an exception.'));
|
||||
}
|
||||
catch (DatabaseTransactionOutOfOrderException $e) {
|
||||
catch (TransactionOutOfOrderException $e) {
|
||||
$this->pass(t('Rolling back the outer transaction while the inner transaction is active resulted in an exception.'));
|
||||
}
|
||||
$this->assertFalse($database->inTransaction(), t('No more in a transaction after rolling back the outer transaction'));
|
||||
|
@ -3717,7 +3718,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
|
|||
unset($transaction2);
|
||||
$this->fail(t('Trying to commit an inner transaction resulted in an exception.'));
|
||||
}
|
||||
catch (DatabaseTransactionNoActiveException $e) {
|
||||
catch (TransactionNoActiveException $e) {
|
||||
$this->pass(t('Trying to commit an inner transaction resulted in an exception.'));
|
||||
}
|
||||
$this->assertRowAbsent('outer');
|
||||
|
@ -3770,9 +3771,9 @@ class DatabaseEmptyStatementTestCase extends DrupalWebTestCase {
|
|||
* Test that the empty result set behaves as empty.
|
||||
*/
|
||||
function testEmpty() {
|
||||
$result = new DatabaseStatementEmpty();
|
||||
$result = new StatementEmpty();
|
||||
|
||||
$this->assertTrue($result instanceof DatabaseStatementInterface, t('Class implements expected interface'));
|
||||
$this->assertTrue($result instanceof StatementInterface, t('Class implements expected interface'));
|
||||
$this->assertNull($result->fetchObject(), t('Null result returned.'));
|
||||
}
|
||||
|
||||
|
@ -3780,7 +3781,7 @@ class DatabaseEmptyStatementTestCase extends DrupalWebTestCase {
|
|||
* Test that the empty result set iterates safely.
|
||||
*/
|
||||
function testEmptyIteration() {
|
||||
$result = new DatabaseStatementEmpty();
|
||||
$result = new StatementEmpty();
|
||||
|
||||
foreach ($result as $record) {
|
||||
$this->fail(t('Iterating empty result set should not iterate.'));
|
||||
|
@ -3794,7 +3795,7 @@ class DatabaseEmptyStatementTestCase extends DrupalWebTestCase {
|
|||
* Test that the empty result set mass-fetches in an expected way.
|
||||
*/
|
||||
function testEmptyFetchAll() {
|
||||
$result = new DatabaseStatementEmpty();
|
||||
$result = new StatementEmpty();
|
||||
|
||||
$this->assertEqual($result->fetchAll(), array(), t('Empty array returned from empty result set.'));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
use Drupal\Database\Query\AlterableInterface;
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hooks provided by Drupal core and the System module.
|
||||
|
@ -2746,7 +2744,7 @@ function hook_schema_alter(&$schema) {
|
|||
* @see AlterableInterface
|
||||
* @see SelectInterface
|
||||
*/
|
||||
function hook_query_alter(AlterableInterface $query) {
|
||||
function hook_query_alter(Drupal\Database\Query\AlterableInterface $query) {
|
||||
if ($query->hasTag('micro_limit')) {
|
||||
$query->range(0, 2);
|
||||
}
|
||||
|
@ -2763,7 +2761,7 @@ function hook_query_alter(AlterableInterface $query) {
|
|||
* @see AlterableInterface
|
||||
* @see SelectInterface
|
||||
*/
|
||||
function hook_query_TAG_alter(AlterableInterface $query) {
|
||||
function hook_query_TAG_alter(Drupal\Database\Query\AlterableInterface $query) {
|
||||
// Skip the extra expensive alterations if site has no node access control modules.
|
||||
if (!node_access_view_all_nodes()) {
|
||||
// Prevent duplicates records.
|
||||
|
|
Loading…
Reference in New Issue