Skip to content

Commit

Permalink
Rename Schema::class to AbstractSchema::class. (#214)
Browse files Browse the repository at this point in the history
* Rename Schema::class to AbstractSchema::class.
  • Loading branch information
terabytesoftw committed Jan 12, 2023
1 parent 6b0f6d9 commit 67af7f0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/Builder/ArrayExpressionBuilder.php
Expand Up @@ -14,9 +14,9 @@
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Expression\JsonExpression;
use Yiisoft\Db\Pgsql\Schema;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\Schema\Schema as AbstractSchema;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\Schema\SchemaInterface;

use function implode;
use function in_array;
Expand Down Expand Up @@ -166,7 +166,7 @@ protected function typecastValue(
return $value;
}

if (in_array($expression->getType(), [AbstractSchema::TYPE_JSON, Schema::TYPE_JSONB], true)) {
if (in_array($expression->getType(), [SchemaInterface::TYPE_JSON, Schema::TYPE_JSONB], true)) {
return new JsonExpression($value);
}

Expand Down
8 changes: 4 additions & 4 deletions src/ColumnSchema.php
Expand Up @@ -11,7 +11,7 @@
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Expression\JsonExpression;
use Yiisoft\Db\Schema\AbstractColumnSchema;
use Yiisoft\Db\Schema\Schema as AbstractSchema;
use Yiisoft\Db\Schema\SchemaInterface;

use function array_walk_recursive;
use function in_array;
Expand Down Expand Up @@ -59,7 +59,7 @@ public function dbTypecast(mixed $value): mixed
return new ArrayExpression($value, $this->getDbType(), $this->dimension);
}

if (in_array($this->getDbType(), [AbstractSchema::TYPE_JSON, Schema::TYPE_JSONB], true)) {
if (in_array($this->getDbType(), [SchemaInterface::TYPE_JSON, Schema::TYPE_JSONB], true)) {
return new JsonExpression($value, $this->getDbType());
}

Expand Down Expand Up @@ -116,7 +116,7 @@ protected function phpTypecastValue(mixed $value): mixed
}

switch ($this->getType()) {
case AbstractSchema::TYPE_BOOLEAN:
case SchemaInterface::TYPE_BOOLEAN:
/** @var mixed */
$value = is_string($value) ? strtolower($value) : $value;

Expand All @@ -125,7 +125,7 @@ protected function phpTypecastValue(mixed $value): mixed
'f', 'false' => false,
default => (bool)$value,
};
case AbstractSchema::TYPE_JSON:
case SchemaInterface::TYPE_JSON:
return json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR);
}

Expand Down
45 changes: 22 additions & 23 deletions src/QueryBuilder.php
Expand Up @@ -6,7 +6,6 @@

use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\Schema;
use Yiisoft\Db\Schema\SchemaInterface;

/**
Expand Down Expand Up @@ -45,28 +44,28 @@ final class QueryBuilder extends AbstractQueryBuilder
* @psalm-var string[]
*/
protected array $typeMap = [
Schema::TYPE_PK => 'serial NOT NULL PRIMARY KEY',
Schema::TYPE_UPK => 'serial NOT NULL PRIMARY KEY',
Schema::TYPE_BIGPK => 'bigserial NOT NULL PRIMARY KEY',
Schema::TYPE_UBIGPK => 'bigserial NOT NULL PRIMARY KEY',
Schema::TYPE_CHAR => 'char(1)',
Schema::TYPE_STRING => 'varchar(255)',
Schema::TYPE_TEXT => 'text',
Schema::TYPE_TINYINT => 'smallint',
Schema::TYPE_SMALLINT => 'smallint',
Schema::TYPE_INTEGER => 'integer',
Schema::TYPE_BIGINT => 'bigint',
Schema::TYPE_FLOAT => 'double precision',
Schema::TYPE_DOUBLE => 'double precision',
Schema::TYPE_DECIMAL => 'numeric(10,0)',
Schema::TYPE_DATETIME => 'timestamp(0)',
Schema::TYPE_TIMESTAMP => 'timestamp(0)',
Schema::TYPE_TIME => 'time(0)',
Schema::TYPE_DATE => 'date',
Schema::TYPE_BINARY => 'bytea',
Schema::TYPE_BOOLEAN => 'boolean',
Schema::TYPE_MONEY => 'numeric(19,4)',
Schema::TYPE_JSON => 'jsonb',
SchemaInterface::TYPE_PK => 'serial NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_UPK => 'serial NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_BIGPK => 'bigserial NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_UBIGPK => 'bigserial NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_CHAR => 'char(1)',
SchemaInterface::TYPE_STRING => 'varchar(255)',
SchemaInterface::TYPE_TEXT => 'text',
SchemaInterface::TYPE_TINYINT => 'smallint',
SchemaInterface::TYPE_SMALLINT => 'smallint',
SchemaInterface::TYPE_INTEGER => 'integer',
SchemaInterface::TYPE_BIGINT => 'bigint',
SchemaInterface::TYPE_FLOAT => 'double precision',
SchemaInterface::TYPE_DOUBLE => 'double precision',
SchemaInterface::TYPE_DECIMAL => 'numeric(10,0)',
SchemaInterface::TYPE_DATETIME => 'timestamp(0)',
SchemaInterface::TYPE_TIMESTAMP => 'timestamp(0)',
SchemaInterface::TYPE_TIME => 'time(0)',
SchemaInterface::TYPE_DATE => 'date',
SchemaInterface::TYPE_BINARY => 'bytea',
SchemaInterface::TYPE_BOOLEAN => 'boolean',
SchemaInterface::TYPE_MONEY => 'numeric(19,4)',
SchemaInterface::TYPE_JSON => 'jsonb',
];
private DDLQueryBuilder $ddlBuilder;
private DMLQueryBuilder $dmlBuilder;
Expand Down
2 changes: 1 addition & 1 deletion src/Schema.php
Expand Up @@ -16,9 +16,9 @@
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Schema\AbstractSchema;
use Yiisoft\Db\Schema\ColumnSchemaBuilder;
use Yiisoft\Db\Schema\ColumnSchemaInterface;
use Yiisoft\Db\Schema\Schema as AbstractSchema;
use Yiisoft\Db\Schema\TableSchemaInterface;

use function array_merge;
Expand Down

0 comments on commit 67af7f0

Please sign in to comment.