This file contains the upgrade notes. These notes highlight changes that could break your application when you upgrade the package from one version to another.
Important! The following upgrading instructions are cumulative. That is, if you want to upgrade from version A to version C and there is version B between A and C, you need to following the instructions for both A and B.
Add ColumnInterface
support and change type of parameter $type
from string
to ColumnInterface|string
in addColumn()
method of your classes that implement the following interfaces:
Yiisoft\Db\Command\CommandInterface
;Yiisoft\Db\QueryBuilder\DDLQueryBuilderInterface
;
… or inherit from the following classes:
Yiisoft\Db\Command\AbstractCommand
;Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder
;Yiisoft\Db\QueryBuilder\AbstractQueryBuilder
.
Change $columns
parameter type from array|string|ExpressionInterface
to array|bool|float|int|string|ExpressionInterface
in methods select()
and addSelect()
of your classes that implement Yiisoft\Db\Query\QueryPartsInterface
.
Add support any scalar values for $columns
parameter of these methods in your classes that implement
Yiisoft\Db\Query\QueryPartsInterface
or inherit Yiisoft\Db\Query\Query
.
ExpressionBuilder
is replaced by an abstract class AbstractExpressionBuilder
with an instance of the
QueryBuilderInterface
parameter in the constructor. Each DBMS driver should implement its own expression builder.
Expression::$params
can contain:
- non-unique placeholder names, they will be replaced with unique names;
Expression
instances, they will be built when building a query usingQueryBuilder
.
batchInsert()
method is renamed to insertBatch()
in DMLQueryBuilderInterface
and CommandInterface
.
The parameters are changed from $table, $columns, $rows
to $table, $rows, $columns = []
.
It allows to use the method without columns, for example:
use Yiisoft\Db\Connection\ConnectionInterface;
$values = [
['name' => 'Tom', 'age' => 30],
['name' => 'Jane', 'age' => 20],
['name' => 'Linda', 'age' => 25],
];
/** @var ConnectionInterface $db */
$db->createCommand()->insertBatch('user', $values)->execute();
The interface and the abstract implementation AbstractColumnSchema
were moved to Yiisoft\Db\Schema\Column
namespace
and the following changes were made:
getName()
method can returnstring
ornull
;getPhpType()
method must returnstring
PHP type of the column which used for generating related model properties;name(string|null $name)
method is added;check(string|null $check)
method is added;getCheck()
method is added;reference(ForeignKeyConstraint|null $reference)
method is added;getReference()
method is added;notNull(bool $notNull = true)
method is added;null()
method is added;isNotNull()
method is added;unique(bool $unique = true)
method is added;isUnique()
method is added;hasDefaultValue()
method is added;- all
AbstractColumnSchema
class properties except$type
moved to constructor; - added
DEFAULT_TYPE
constant toAbstractColumnSchema
class; - added method chaining.
Yiisoft\Db\Constant\PhpType
with PHP types constants;Yiisoft\Db\Constant\GettypeResult
withgettype()
function results constants.Yiisoft\Db\Constant\ColumnType
with abstract column types constants.Yiisoft\Db\Constant\PseudoType
with column pseudo-types constants.
Each table column has its own class in the Yiisoft\Db\Schema\Column
namespace according to the data type:
BooleanColumnSchema
for columns with boolean type;BitColumnSchema
for columns with bit type;IntegerColumnSchema
for columns with integer type (tinyint, smallint, integer, bigint);BigIntColumnSchema
for columns with integer type with range outsidePHP_INT_MIN
andPHP_INT_MAX
;DoubleColumnSchema
for columns with fractional number type (float, double, decimal, money);StringColumnSchema
for columns with string or datetime type (char, string, text, datetime, timestamp, date, time);BinaryColumnSchema
for columns with binary type;ArrayColumnSchema
for columns with array type;StructuredColumnSchema
for columns with structured type (composite type in PostgreSQL);JsonColumnSchema
for columns with json type.
QuoterInterface::getRawTableName()
- returns the raw table name without quotes;SchemaInterface::getColumnFactory()
- returns the column factory object for concrete DBMS;QueryBuilderInterface::buildColumnDefinition()
- builds column definition forCREATE TABLE
statement;QueryBuilderInterface::prepareParam()
- converts aParamInterface
object to its SQL representation;QueryBuilderInterface::prepareValue()
- converts a value to its SQL representation;
AbstractDMLQueryBuilder::getTypecastValue()
TableSchemaInterface::compositeForeignKey()
SchemaInterface::isReadQuery()
AbstractSchema::isReadQuery()
SchemaInterface::getRawTableName()
AbstractSchema::getRawTableName()
AbstractSchema::normalizeRowKeyCase()
Quoter::unquoteParts()
AbstractPdoCommand::logQuery()
ColumnSchemaInterface::phpType()
$table
fromAbstractDMLQueryBuilder::normalizeColumnNames()
method$table
fromAbstractDMLQueryBuilder::getNormalizeColumnNames()
method$withColumn
fromQuoterInterface::getTableNameParts()
method$rawSql
fromAbstractCommand::internalExecute()
method$rawSql
fromAbstractPdoCommand::internalExecute()
method
SchemaInterface::TYPE_JSONB
SchemaInterface::PHP_TYPE_INTEGER
SchemaInterface::PHP_TYPE_STRING
SchemaInterface::PHP_TYPE_BOOLEAN
SchemaInterface::PHP_TYPE_DOUBLE
SchemaInterface::PHP_TYPE_RESOURCE
SchemaInterface::PHP_TYPE_ARRAY
SchemaInterface::PHP_TYPE_NULL
- Allow
ExpressionInterface
for$alias
parameter ofQueryPartsInterface::withQuery()
method; - Allow
QueryInterface::one()
to return an object; - Allow
QueryInterface::all()
to return array of objects; - Change
Quoter::quoteValue()
parameter type and return type frommixed
tostring
;