Browse Source

Rename DefaultConstraint to DefaultValueConstraint

tags/2.0.13
Sergey Makinen 7 years ago
parent
commit
3de6f8e397
No known key found for this signature in database
GPG Key ID: D227B0B214A978D6
  1. 13
      framework/db/ConstraintFinderTrait.php
  2. 4
      framework/db/DefaultValueConstraint.php
  3. 4
      framework/db/mssql/Schema.php
  4. 4
      tests/framework/db/mssql/SchemaTest.php

13
framework/db/ConstraintFinderTrait.php

@ -12,8 +12,8 @@ namespace yii\db;
*
* @property CheckConstraint[][] $schemaChecks Check constraints for all tables in the database.
* Each array element is an array of [[CheckConstraint]] or its child classes. This property is read-only.
* @property DefaultConstraint[] $schemaDefaultValues Default value constraints for all tables in the database.
* Each array element is an array of [[DefaultConstraint]] or its child classes. This property is read-only.
* @property DefaultValueConstraint[] $schemaDefaultValues Default value constraints for all tables in the database.
* Each array element is an array of [[DefaultValueConstraint]] or its child classes. This property is read-only.
* @property ForeignKeyConstraint[][] $schemaForeignKeys Foreign keys for all tables in the database. Each
* array element is an array of [[ForeignKeyConstraint]] or its child classes. This property is read-only.
* @property IndexConstraint[][] $schemaIndexes Indexes for all tables in the database. Each array element is
@ -65,8 +65,9 @@ trait ConstraintFinderTrait
/**
* Loads all default value constraints for the given table.
*
* @param string $tableName table name.
* @return DefaultConstraint[] default value constraints for the given table.
* @return DefaultValueConstraint[] default value constraints for the given table.
*/
abstract protected function loadTableDefaultValues($tableName);
@ -194,7 +195,7 @@ trait ConstraintFinderTrait
* Obtains the default value constraints information 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 bool $refresh whether to reload the information even if it is found in the cache.
* @return DefaultConstraint[] table default value constraints.
* @return DefaultValueConstraint[] table default value constraints.
*/
public function getTableDefaultValues($name, $refresh = false)
{
@ -206,8 +207,8 @@ trait ConstraintFinderTrait
* @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema name.
* @param bool $refresh whether to fetch the latest available table schemas. If this is false,
* cached data may be returned if available.
* @return DefaultConstraint[] default value constraints for all tables in the database.
* Each array element is an array of [[DefaultConstraint]] or its child classes.
* @return DefaultValueConstraint[] default value constraints for all tables in the database.
* Each array element is an array of [[DefaultValueConstraint]] or its child classes.
*/
public function getSchemaDefaultValues($schema = '', $refresh = false)
{

4
framework/db/DefaultConstraint.php → framework/db/DefaultValueConstraint.php

@ -8,12 +8,12 @@
namespace yii\db;
/**
* DefaultConstraint represents the metadata of a table `DEFAULT` constraint.
* DefaultValueConstraint represents the metadata of a table `DEFAULT` constraint.
*
* @author Sergey Makinen <sergey@makinen.ru>
* @since 2.0.13
*/
class DefaultConstraint extends Constraint
class DefaultValueConstraint extends Constraint
{
/**
* @var mixed default value as returned by the DBMS.

4
framework/db/mssql/Schema.php

@ -11,7 +11,7 @@ use yii\db\CheckConstraint;
use yii\db\ColumnSchema;
use yii\db\Constraint;
use yii\db\ConstraintFinderTrait;
use yii\db\DefaultConstraint;
use yii\db\DefaultValueConstraint;
use yii\db\ForeignKeyConstraint;
use yii\db\IndexConstraint;
use yii\db\ViewFinderTrait;
@ -687,7 +687,7 @@ SQL;
]);
break;
case 'D':
$result['defaults'][] = new DefaultConstraint([
$result['defaults'][] = new DefaultValueConstraint([
'name' => $name,
'columnNames' => ArrayHelper::getColumn($constraint, 'column_name'),
'value' => $constraint[0]['default_expr'],

4
tests/framework/db/mssql/SchemaTest.php

@ -7,7 +7,7 @@
namespace yiiunit\framework\db\mssql;
use yii\db\DefaultConstraint;
use yii\db\DefaultValueConstraint;
use yiiunit\framework\db\AnyValue;
/**
@ -22,7 +22,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest
{
$result = parent::constraintsProvider();
$result['1: check'][2][0]->expression = '([C_check]<>\'\')';
$result['1: default'][2][] = new DefaultConstraint([
$result['1: default'][2][] = new DefaultValueConstraint([
'name' => AnyValue::getInstance(),
'columnNames' => ['C_default'],
'value' => '((0))',

Loading…
Cancel
Save