Skip to content

Commit 399a47f

Browse files
authored
Rename class ColumnSchemaBuilder (#251)
* Rename class ColumnSchemaBuilder * Merge branch 'master' of github.com:darkdef/db-mysql into columnbuilder # Conflicts: # src/QueryBuilder.php # src/Schema.php Merge branch 'master' of github.com:darkdef/db-mssql into columnbuilder # Conflicts: # src/DDLQueryBuilder.php * merges and bugfixes
1 parent 54ca29e commit 399a47f

4 files changed

Lines changed: 24 additions & 26 deletions

File tree

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44

55
namespace Yiisoft\Db\Pgsql;
66

7-
use Yiisoft\Db\Schema\AbstractColumnSchemaBuilder;
7+
use Yiisoft\Db\Schema\Builder\AbstractColumn;
88

99
/**
10-
* It's a utility that provides a convenient way to create column schema for use with {@see Schema} for PostgreSQL
11-
* Server.
10+
* It's a utility that provides a convenient way to create column schema for use with {@see `\Yiisoft\Db\Pgsql\Schema`}
11+
* for PostgreSQL.
1212
*
1313
* It provides methods for specifying the properties of a column, such as its type, size, default value, and whether it
1414
* is nullable or not. It also provides a method for creating a column schema based on the specified properties.
1515
*
1616
* For example, the following code creates a column schema for an integer column:
1717
*
1818
* ```php
19-
* $column = (new ColumnSchemaBuilder(SchemaInterface::TYPE_INTEGER))->notNull()->defaultValue(0);
19+
* $column = (new Column(SchemaInterface::TYPE_INTEGER))->notNull()->defaultValue(0);
2020
* ```
2121
*
2222
* Provides a fluent interface, which means that the methods can be chained together to create a column schema with
2323
* many properties in a single line of code.
2424
*/
25-
final class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
25+
final class Column extends AbstractColumn
2626
{
2727
}

src/DDLQueryBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Yiisoft\Db\Exception\NotSupportedException;
99
use Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder;
1010
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
11-
use Yiisoft\Db\Schema\ColumnSchemaBuilderInterface;
11+
use Yiisoft\Db\Schema\Builder\ColumnInterface;
1212
use Yiisoft\Db\Schema\QuoterInterface;
1313
use Yiisoft\Db\Schema\SchemaInterface;
1414

@@ -38,12 +38,12 @@ public function addDefaultValue(string $name, string $table, string $column, mix
3838
throw new NotSupportedException(__METHOD__ . ' is not supported by PostgreSQL.');
3939
}
4040

41-
public function alterColumn(string $table, string $column, ColumnSchemaBuilderInterface|string $type): string
41+
public function alterColumn(string $table, string $column, ColumnInterface|string $type): string
4242
{
4343
$columnName = $this->quoter->quoteColumnName($column);
4444
$tableName = $this->quoter->quoteTableName($table);
4545

46-
if ($type instanceof ColumnSchemaBuilderInterface) {
46+
if ($type instanceof ColumnInterface) {
4747
$type = $type->asString();
4848
}
4949

src/Schema.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Yiisoft\Db\Expression\Expression;
1818
use Yiisoft\Db\Helper\ArrayHelper;
1919
use Yiisoft\Db\Schema\AbstractSchema;
20-
use Yiisoft\Db\Schema\ColumnSchemaBuilderInterface;
20+
use Yiisoft\Db\Schema\Builder\ColumnInterface;
2121
use Yiisoft\Db\Schema\ColumnSchemaInterface;
2222
use Yiisoft\Db\Schema\TableSchemaInterface;
2323

@@ -166,6 +166,11 @@ final class Schema extends AbstractSchema
166166
*/
167167
protected string|array $tableQuoteCharacter = '"';
168168

169+
public function createColumn(string $type, array|int|string $length = null): ColumnInterface
170+
{
171+
return new Column($type, $length);
172+
}
173+
169174
/**
170175
* Resolves the table name and schema name (if any).
171176
*
@@ -1050,13 +1055,6 @@ private function createColumnSchema(): ColumnSchema
10501055
return new ColumnSchema();
10511056
}
10521057

1053-
public function createColumnSchemaBuilder(
1054-
string $type,
1055-
int|string|array|null $length = null
1056-
): ColumnSchemaBuilderInterface {
1057-
return new ColumnSchemaBuilder($type, $length);
1058-
}
1059-
10601058
/**
10611059
* Returns the cache key for the specified table name.
10621060
*

tests/QueryBuilderTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Yiisoft\Db\Exception\InvalidConfigException;
1313
use Yiisoft\Db\Exception\NotSupportedException;
1414
use Yiisoft\Db\Expression\ExpressionInterface;
15-
use Yiisoft\Db\Pgsql\ColumnSchemaBuilder;
15+
use Yiisoft\Db\Pgsql\Column;
1616
use Yiisoft\Db\Pgsql\Tests\Support\TestTrait;
1717
use Yiisoft\Db\Query\QueryInterface;
1818
use Yiisoft\Db\Schema\SchemaInterface;
@@ -96,7 +96,7 @@ public function testAlterColumn(): void
9696
$qb->alterColumn(
9797
'foo1',
9898
'bar',
99-
(new ColumnSchemaBuilder(SchemaInterface::TYPE_STRING, 255))->asString()
99+
(new Column(SchemaInterface::TYPE_STRING, 255))->asString()
100100
),
101101
);
102102

@@ -121,7 +121,7 @@ public function testAlterColumn(): void
121121
$qb->alterColumn(
122122
'foo1',
123123
'bar',
124-
(new ColumnSchemaBuilder(SchemaInterface::TYPE_STRING, 255))->notNull()->asString()
124+
(new Column(SchemaInterface::TYPE_STRING, 255))->notNull()->asString()
125125
),
126126
);
127127

@@ -132,7 +132,7 @@ public function testAlterColumn(): void
132132
$qb->alterColumn(
133133
'foo1',
134134
'bar',
135-
(new ColumnSchemaBuilder(SchemaInterface::TYPE_STRING, 255))->null()->asString()
135+
(new Column(SchemaInterface::TYPE_STRING, 255))->null()->asString()
136136
),
137137
);
138138

@@ -143,7 +143,7 @@ public function testAlterColumn(): void
143143
$qb->alterColumn(
144144
'foo1',
145145
'bar',
146-
(new ColumnSchemaBuilder(SchemaInterface::TYPE_STRING, 255))->null()->defaultValue('xxx')->asString()
146+
(new Column(SchemaInterface::TYPE_STRING, 255))->null()->defaultValue('xxx')->asString()
147147
),
148148
);
149149

@@ -154,7 +154,7 @@ public function testAlterColumn(): void
154154
$qb->alterColumn(
155155
'foo1',
156156
'bar',
157-
(new ColumnSchemaBuilder(SchemaInterface::TYPE_STRING, 255))->check('char_length(bar) > 5')->asString()
157+
(new Column(SchemaInterface::TYPE_STRING, 255))->check('char_length(bar) > 5')->asString()
158158
),
159159
);
160160

@@ -165,7 +165,7 @@ public function testAlterColumn(): void
165165
$qb->alterColumn(
166166
'foo1',
167167
'bar',
168-
(new ColumnSchemaBuilder(SchemaInterface::TYPE_STRING, 255))->defaultValue('')->asString()
168+
(new Column(SchemaInterface::TYPE_STRING, 255))->defaultValue('')->asString()
169169
),
170170
);
171171

@@ -176,7 +176,7 @@ public function testAlterColumn(): void
176176
$qb->alterColumn(
177177
'foo1',
178178
'bar',
179-
(new ColumnSchemaBuilder(SchemaInterface::TYPE_STRING, 255))->defaultValue('AbCdE')->asString()
179+
(new Column(SchemaInterface::TYPE_STRING, 255))->defaultValue('AbCdE')->asString()
180180
),
181181
);
182182

@@ -187,7 +187,7 @@ public function testAlterColumn(): void
187187
$qb->alterColumn(
188188
'foo1',
189189
'bar',
190-
(new ColumnSchemaBuilder(SchemaInterface::TYPE_TIMESTAMP))
190+
(new Column(SchemaInterface::TYPE_TIMESTAMP))
191191
->defaultExpression('CURRENT_TIMESTAMP')
192192
->asString()
193193
),
@@ -200,7 +200,7 @@ public function testAlterColumn(): void
200200
$qb->alterColumn(
201201
'foo1',
202202
'bar',
203-
(new ColumnSchemaBuilder(SchemaInterface::TYPE_STRING, 30))->unique()->asString()
203+
(new Column(SchemaInterface::TYPE_STRING, 30))->unique()->asString()
204204
),
205205
);
206206

0 commit comments

Comments
 (0)