Skip to content

Commit

Permalink
Fixes (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark authored Mar 27, 2023
1 parent 2029c78 commit 71f0aa1
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/Builder/JsonExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use function count;

/**
* Builds expressions for {@see `Yiisoft\Db\Expression\JsonExpression`} for MySQL, MariaDb Server.
* Builds expressions for {@see `Yiisoft\Db\Expression\JsonExpression`} for MySQL, MariaDB.
*/
final class JsonExpressionBuilder implements ExpressionBuilderInterface
{
Expand Down
13 changes: 5 additions & 8 deletions src/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

use Exception;
use Yiisoft\Db\Schema\Builder\AbstractColumn;
use Yiisoft\Db\Schema\QuoterInterface;

/**
* It's a utility that provides a convenient way to create column schema for use with {@see `\Yiisoft\Db\Mysql\Schema`}
* for MySQL, MariaDb Server.
* Provides a convenient way to create column schema for use with {@see `\Yiisoft\Db\Mysql\Schema`}
* for MySQL, MariaDB.
*
* It provides methods for specifying the properties of a column, such as its type, size, default value, and whether it
* It has methods for specifying the properties of a column, such as its type, size, default value, and whether it
* is nullable or not. It also provides a method for creating a column schema based on the specified properties.
*
* For example, the following code creates a column schema for an integer column:
Expand All @@ -26,12 +25,10 @@
*/
final class Column extends AbstractColumn
{
private QuoterInterface|null $quoter = null;

/**
* Builds the unsigned string for column. Defaults to unsupported.
*
* @return string a string containing UNSIGNED keyword.
* @return string A string containing `UNSIGNED` keyword.
*/
protected function buildUnsignedString(): string
{
Expand All @@ -43,7 +40,7 @@ protected function buildUnsignedString(): string
*
* @throws Exception
*
* @return string a string containing the COMMENT keyword and the comment itself.
* @return string A string containing the `COMMENT` keyword and the comment itself.
*/
protected function buildCommentString(): string
{
Expand Down
8 changes: 4 additions & 4 deletions src/ColumnSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
use function json_decode;

/**
* Represents the metadata of a column in a database table for MySQL, MariaDb Server.
* Represents the metadata of a column in a database table for MySQL, MariaDB.
*
* It provides information about the column's name, type, size, precision, and other details.
*
* Is used to store and retrieve metadata about a column in a database table. It's typically used in conjunction with
* It's used to store and retrieve metadata about a column in a database table, typically in conjunction with
* the {@see TableSchema}, which represents the metadata of a database table as a whole.
*
* The following code shows how to use:
Expand All @@ -43,7 +43,7 @@ final class ColumnSchema extends AbstractColumnSchema
*
* If the value is `null` or an {@see \Yiisoft\Db\Expression\Expression}, it won't be converted.
*
* @param mixed $value The value to be converted.
* @param mixed $value The value to convert.
*
* @throws JsonException If the value can't be decoded.
*
Expand All @@ -67,7 +67,7 @@ public function phpTypecast(mixed $value): mixed
*
* If the value is `null` or an {@see \Yiisoft\Db\Expression\Expression}, it won't be converted.
*
* @param mixed $value The value to be converted.
* @param mixed $value The value to convert.
*
* @return mixed The converted value. This may also be an array containing the value as the first element and the
* PDO type as the second element.
Expand Down
4 changes: 2 additions & 2 deletions src/CommandPDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;

/**
* Implements a database command that can be executed against a PDO (PHP Data Object) database connection for MySQL,
* MariaDb Server.
* Implements a database command that can be executed with a PDO (PHP Data Object) database connection for MySQL,
* MariaDB.
*/
final class CommandPDO extends AbstractCommandPDO
{
Expand Down
2 changes: 1 addition & 1 deletion src/ConnectionPDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Yiisoft\Db\Transaction\TransactionInterface;

/**
* Implements a connection to a database via PDO (PHP Data Objects) for MySQL, MariaDb Server.
* Implements a connection to a database via PDO (PHP Data Objects) for MySQL, MariaDB.
*
* @link https://www.php.net/manual/en/ref.pdo-mysql.php
*/
Expand Down
2 changes: 1 addition & 1 deletion src/DDLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use function trim;

/**
* Implements a (Data Definition Language) SQL statements for MySQL, MariaDb Server.
* Implements a (Data Definition Language) SQL statements for MySQL, MariaDB.
*/
final class DDLQueryBuilder extends AbstractDDLQueryBuilder
{
Expand Down
10 changes: 5 additions & 5 deletions src/DMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use function reset;

/**
* Implements a DML (Data Manipulation Language) SQL statements for MySQL, MariaDb Server.
* Implements a DML (Data Manipulation Language) SQL statements for MySQL, MariaDB.
*/
final class DMLQueryBuilder extends AbstractDMLQueryBuilder
{
Expand Down Expand Up @@ -115,9 +115,9 @@ public function upsert(
/**
* Prepares a `VALUES` part for an `INSERT` SQL statement.
*
* @param string $table The table that new rows will be inserted into.
* @param array|QueryInterface $columns The column data (name => value) to be inserted into the table or instance of
* {@see Query} to perform INSERT INTO ... SELECT SQL statement.
* @param string $table The table to insert new rows into.
* @param array|QueryInterface $columns The column data (name => value) to insert into the table or instance of
* {@see Query} to perform `INSERT INTO ... SELECT` SQL statement.
* @param array $params The binding parameters that will be generated by this method.
* They should be bound to the DB command later.
*
Expand All @@ -126,7 +126,7 @@ public function upsert(
* @throws InvalidConfigException
* @throws NotSupportedException
*
* @return array Array of column names, placeholders, values and params.
* @return array Array of column names, placeholders, values, and params.
*/
protected function prepareInsertValues(string $table, QueryInterface|array $columns, array $params = []): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/DQLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use function ctype_digit;

/**
* Implements a DQL (Data Query Language) SQL statements for MySQL, MariaDb Server.
* Implements a DQL (Data Query Language) SQL statements for MySQL, MariaDB.
*/
final class DQLQueryBuilder extends AbstractDQLQueryBuilder
{
Expand Down
2 changes: 1 addition & 1 deletion src/Dsn.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Yiisoft\Db\Connection\AbstractDsn;

/**
* Implement a Data Source Name (DSN) for an MySQL, MariaDb Server.
* Implement a Data Source Name (DSN) for an MySQL, MariaDB.
*
* @link https://www.php.net/manual/en/ref.pdo-mysql.connection.php
*/
Expand Down
2 changes: 1 addition & 1 deletion src/DsnSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Yiisoft\Db\Connection\AbstractDsnSocket;

/**
* Implement a Data Source Name (DSN) with unix socket for an MySQL, MariaDb Server.
* Implement a Data Source Name (DSN) with unix socket for an MySQL, MariaDB.
*
* @link https://www.php.net/manual/en/ref.pdo-mysql.connection.php
*/
Expand Down
4 changes: 2 additions & 2 deletions src/PDODriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Yiisoft\Db\Driver\PDO\AbstractPDODriver;

/**
* Implements the MySQL, MariaDb Server driver based on the PDO (PHP Data Objects) extension.
* Implements the MySQL, MariaDB driver based on the PDO (PHP Data Objects) extension.
*
* @link https://www.php.net/manual/en/ref.pdo-mysql.php
*/
Expand All @@ -28,7 +28,7 @@ public function createConnection(): PDO
$pdo->exec('SET NAMES ' . $pdo->quote($this->charset));
}

if (!str_contains($this->dsn, 'charset') && $this->charset === null) {
if ($this->charset === null && !str_contains($this->dsn, 'charset')) {
$pdo->exec('SET NAMES ' . $pdo->quote('utf8mb4'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Yiisoft\Db\Schema\SchemaInterface;

/**
* Implements the MySQL, MariaDb Server specific query builder.
* Implements MySQL, MariaDB specific query builder.
*/
final class QueryBuilder extends AbstractQueryBuilder
{
Expand Down
2 changes: 1 addition & 1 deletion src/Quoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function str_replace;

/**
* Implements the MySQL, MariaDb Server quoting and unquoting methods.
* Implements MySQL, MariaDB quoting and unquoting methods.
*/
final class Quoter extends BaseQuoter
{
Expand Down
19 changes: 9 additions & 10 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
use function trim;

/**
* Implements the Mysql, Mariadb Server specific schema, supporting Mysql Server 5.7, Mariadb Server 10.4 and higher
* versions.
* Implements MySQL, MariaDB specific schema, supporting MySQL Server 5.7, MariaDB Server 10.4 and higher.
*
* @psalm-type ColumnArray = array{
* table_schema: string,
Expand Down Expand Up @@ -193,7 +192,7 @@ protected function findColumns(TableSchemaInterface $table): bool

try {
$columns = $this->db->createCommand($sql)->queryAll();
// Chapter 1: cruthes for MariaDB. {@see https://github.com/yiisoft/yii2/issues/19747}
// Chapter 1: crutches for MariaDB. {@see https://github.com/yiisoft/yii2/issues/19747}
$columnsExtra = [];
if (str_contains($this->db->getServerVersion(), 'MariaDB')) {
/** @psalm-var array[] $columnsExtra */
Expand Down Expand Up @@ -430,15 +429,15 @@ protected function getCacheTag(): string
}

/**
* Gets the CREATE TABLE sql string.
* Gets the `CREATE TABLE` SQL string.
*
* @param TableSchemaInterface $table The table metadata.
*
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @return string $sql The result of 'SHOW CREATE TABLE'.
* @return string $sql The result of `SHOW CREATE TABLE`.
*/
protected function getCreateTableSql(TableSchemaInterface $table): string
{
Expand Down Expand Up @@ -521,10 +520,10 @@ protected function loadColumnSchema(array $info): ColumnSchemaInterface
$column->scale((int) $values[1]);
}

if ($column->getSize() === 1 && $type === 'bit') {
$column->type(self::TYPE_BOOLEAN);
} elseif ($type === 'bit') {
if ($column->getSize() > 32) {
if ($type === 'bit') {
if ($column->getSize() === 1) {
$column->type(self::TYPE_BOOLEAN);
} elseif ($column->getSize() > 32) {
$column->type(self::TYPE_BIGINT);
} elseif ($column->getSize() === 32) {
$column->type(self::TYPE_INTEGER);
Expand All @@ -537,7 +536,7 @@ protected function loadColumnSchema(array $info): ColumnSchemaInterface
$column->phpType($this->getColumnPhpType($column));

if (!$column->isPrimaryKey()) {
// Chapter 2: cruthes for MariaDB {@see https://github.com/yiisoft/yii2/issues/19747}
// Chapter 2: crutches for MariaDB {@see https://github.com/yiisoft/yii2/issues/19747}
/** @psalm-var string $columnCategory */
$columnCategory = $this->createColumn(
$column->getType(),
Expand Down
2 changes: 1 addition & 1 deletion src/TableSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Yiisoft\Db\Schema\AbstractTableSchema;

/**
* Implements the MySQL, MariaDb Server specific table schema.
* Implements MySQL, MariaDB specific table schema.
*/
final class TableSchema extends AbstractTableSchema
{
Expand Down
2 changes: 1 addition & 1 deletion src/TransactionPDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Yiisoft\Db\Driver\PDO\AbstractTransactionPDO;

/**
* Implements the MySQL, MariaDb Server specific transaction.
* Implements the MySQL, MariaDB specific transaction.
*/
final class TransactionPDO extends AbstractTransactionPDO
{
Expand Down

0 comments on commit 71f0aa1

Please sign in to comment.