"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/ORM/Table.php" between
cakephp-4.0.1.tar.gz and cakephp-4.0.2.tar.gz

About: CakePHP is a rapid development framework for PHP applications. Source code.

Table.php  (cakephp-4.0.1):Table.php  (cakephp-4.0.2)
skipping to change at line 22 skipping to change at line 22
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoun dation.org) * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoun dation.org)
* @link https://cakephp.org CakePHP(tm) Project * @link https://cakephp.org CakePHP(tm) Project
* @since 3.0.0 * @since 3.0.0
* @license https://opensource.org/licenses/mit-license.php MIT License * @license https://opensource.org/licenses/mit-license.php MIT License
*/ */
namespace Cake\ORM; namespace Cake\ORM;
use ArrayObject; use ArrayObject;
use BadMethodCallException; use BadMethodCallException;
use Cake\Core\App; use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Database\Connection; use Cake\Database\Connection;
use Cake\Database\Schema\TableSchemaInterface; use Cake\Database\Schema\TableSchemaInterface;
use Cake\Database\TypeFactory; use Cake\Database\TypeFactory;
use Cake\Datasource\ConnectionManager; use Cake\Datasource\ConnectionManager;
use Cake\Datasource\EntityInterface; use Cake\Datasource\EntityInterface;
use Cake\Datasource\Exception\InvalidPrimaryKeyException; use Cake\Datasource\Exception\InvalidPrimaryKeyException;
use Cake\Datasource\RepositoryInterface; use Cake\Datasource\RepositoryInterface;
use Cake\Datasource\RulesAwareTrait; use Cake\Datasource\RulesAwareTrait;
use Cake\Event\EventDispatcherInterface; use Cake\Event\EventDispatcherInterface;
use Cake\Event\EventDispatcherTrait; use Cake\Event\EventDispatcherTrait;
skipping to change at line 501 skipping to change at line 502
* @return \Cake\Database\Schema\TableSchemaInterface * @return \Cake\Database\Schema\TableSchemaInterface
*/ */
public function getSchema(): TableSchemaInterface public function getSchema(): TableSchemaInterface
{ {
if ($this->_schema === null) { if ($this->_schema === null) {
$this->_schema = $this->_initializeSchema( $this->_schema = $this->_initializeSchema(
$this->getConnection() $this->getConnection()
->getSchemaCollection() ->getSchemaCollection()
->describe($this->getTable()) ->describe($this->getTable())
); );
if (Configure::read('debug')) {
$this->checkAliasLengths();
}
} }
return $this->_schema; return $this->_schema;
} }
/** /**
* Sets the schema table object describing this table's properties. * Sets the schema table object describing this table's properties.
* *
* If an array is passed, a new TableSchemaInterface will be constructed * If an array is passed, a new TableSchemaInterface will be constructed
* out of it and used as the schema for this table. * out of it and used as the schema for this table.
skipping to change at line 533 skipping to change at line 537
} }
$schema = $this->getConnection()->getDriver()->newTableSchema($this- >getTable(), $schema); $schema = $this->getConnection()->getDriver()->newTableSchema($this- >getTable(), $schema);
foreach ($constraints as $name => $value) { foreach ($constraints as $name => $value) {
$schema->addConstraint($name, $value); $schema->addConstraint($name, $value);
} }
} }
$this->_schema = $schema; $this->_schema = $schema;
if (Configure::read('debug')) {
$this->checkAliasLengths();
}
return $this; return $this;
} }
/** /**
* Checks if all table name + column name combinations used for
* queries fit into the max length allowed by database driver.
*
* @return void
* @throws \RuntimeException When an alias combination is too long
*/
protected function checkAliasLengths(): void
{
if ($this->_schema === null) {
throw new RuntimeException("Unable to check max alias lengths for `
{$this->getAlias()}` without schema.");
}
$maxLength = null;
if (method_exists($this->getConnection()->getDriver(), "getMaxAliasLengt
h")) {
$maxLength = $this->getConnection()->getDriver()->getMaxAliasLength(
);
}
if ($maxLength === null) {
return;
}
$table = $this->getAlias();
foreach ($this->_schema->columns() as $name) {
if (strlen($table . '__' . $name) > $maxLength) {
$nameLength = $maxLength - 2;
throw new RuntimeException(
"ORM queries generate field aliases using the table name/ali
as and column name. " .
"The table alias `{$table}` and column `{$name}` create an a
lias longer than ({$nameLength}). " .
"You must change the table schema in the database and shorte
n either the table or column " .
"identifier so they fit within the database alias limits."
);
}
}
}
/**
* Override this function in order to alter the schema used by this table. * Override this function in order to alter the schema used by this table.
* This function is only called after fetching the schema out of the databas e. * This function is only called after fetching the schema out of the databas e.
* If you wish to provide your own schema to this table without touching the * If you wish to provide your own schema to this table without touching the
* database, you can override schema() or inject the definitions though that * database, you can override schema() or inject the definitions though that
* method. * method.
* *
* ### Example: * ### Example:
* *
* ``` * ```
* protected function _initializeSchema(\Cake\Database\Schema\TableSchemaInt erface $schema) { * protected function _initializeSchema(\Cake\Database\Schema\TableSchemaInt erface $schema) {
skipping to change at line 2211 skipping to change at line 2253
/** /**
* Deletes multiple entities of a table. * Deletes multiple entities of a table.
* *
* The records will be deleted in a transaction which will be rolled back if * The records will be deleted in a transaction which will be rolled back if
* any one of the records fails to delete due to failed validation or databa se * any one of the records fails to delete due to failed validation or databa se
* error. * error.
* *
* @param \Cake\Datasource\EntityInterface[]|\Cake\Datasource\ResultSetInter face $entities Entities to delete. * @param \Cake\Datasource\EntityInterface[]|\Cake\Datasource\ResultSetInter face $entities Entities to delete.
* @param array|\ArrayAccess $options Options used when calling Table::save( ) for each entity. * @param array|\ArrayAccess $options Options used when calling Table::save( ) for each entity.
* @return bool|\Cake\Datasource\EntityInterface[]|\Cake\Datasource\ResultSe * @return \Cake\Datasource\EntityInterface[]|\Cake\Datasource\ResultSetInte
tInterface rface|false Entities list
* False on failure, entities list on success. * on success, false on failure.
* @throws \Exception * @throws \Exception
* @see \Cake\ORM\Table::delete() for options and events related to this met hod. * @see \Cake\ORM\Table::delete() for options and events related to this met hod.
*/ */
public function deleteMany(iterable $entities, $options = []) public function deleteMany(iterable $entities, $options = [])
{ {
$failed = $this->_deleteMany($entities, $options); $failed = $this->_deleteMany($entities, $options);
if ($failed !== null) { if ($failed !== null) {
return false; return false;
} }
 End of changes. 5 change blocks. 
3 lines changed or deleted 51 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)