Skip to content

Commit d7155ca

Browse files
authored
Merge pull request #12 from aszenz/master
deps: Upgrade to dbal v3
2 parents 343a3f0 + 0200aaf commit d7155ca

File tree

8 files changed

+128
-80
lines changed

8 files changed

+128
-80
lines changed

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
jobs:
9+
test:
10+
name: "Test"
11+
runs-on: "ubuntu-latest"
12+
13+
strategy:
14+
matrix:
15+
php-version:
16+
# PHPUnit v10 needs PHP 8.1, hence no way to test on older php versions
17+
- "8.1"
18+
- "8.2"
19+
- "8.3"
20+
dependencies:
21+
- "lowest"
22+
- "highest"
23+
exclude:
24+
# Exclude lowest deps version as they don't support newer php versions
25+
- dependencies: "lowest"
26+
php-version: "8.3"
27+
- dependencies: "lowest"
28+
php-version: "8.2"
29+
- dependencies: "lowest"
30+
php-version: "8.1"
31+
32+
steps:
33+
- name: "Checkout"
34+
uses: "actions/checkout@v4"
35+
36+
- name: "Install PHP"
37+
uses: "shivammathur/setup-php@v2"
38+
with:
39+
coverage: "xdebug"
40+
php-version: "${{ matrix.php-version }}"
41+
ini-values: "zend.assertions=1"
42+
43+
- uses: "ramsey/composer-install@v2"
44+
with:
45+
dependency-versions: "${{ matrix.dependencies }}"
46+
47+
- name: "Run PHPUnit"
48+
run: "vendor/bin/phpunit -c phpunit.xml.dist"
49+
50+
- name: Upload coverage results to Coveralls
51+
env:
52+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: |
54+
vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/vendor/
22
/composer.lock
33
/build/
4-
/phpunit.xml
4+
/phpunit.xml
5+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=7.1",
13-
"doctrine/dbal": "^2.3",
12+
"php": "^7.4 || ^8.0",
13+
"doctrine/dbal": "^3.0",
1414
"doctrine/inflector": "^1.0 || ^2.0"
1515
},
1616
"require-dev": {
1717
"phpunit/phpunit": "^10.2",
18-
"satooshi/php-coveralls": "^1.0"
18+
"php-coveralls/php-coveralls": "^2.0.0"
1919
},
2020
"autoload": {
2121
"psr-4": {

src/FluidColumn.php

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Doctrine\DBAL\Schema\Column;
77
use Doctrine\DBAL\Schema\Table;
88
use Doctrine\DBAL\Types\Type;
9+
use Doctrine\DBAL\Types\Types;
910

1011
class FluidColumn
1112
{
@@ -48,56 +49,56 @@ public function __construct(FluidSchema $fluidSchema, FluidTable $fluidTable, Ta
4849

4950
public function integer(): FluidColumnOptions
5051
{
51-
$this->column->setType(Type::getType(Type::INTEGER));
52+
$this->column->setType(Type::getType(Types::INTEGER));
5253
return $this->getOptions();
5354
}
5455

5556
public function smallInt(): FluidColumnOptions
5657
{
57-
$this->column->setType(Type::getType(Type::SMALLINT));
58+
$this->column->setType(Type::getType(Types::SMALLINT));
5859
return $this->getOptions();
5960
}
6061

6162
public function bigInt(): FluidColumnOptions
6263
{
63-
$this->column->setType(Type::getType(Type::BIGINT));
64+
$this->column->setType(Type::getType(Types::BIGINT));
6465
return $this->getOptions();
6566
}
6667

6768
public function decimal(int $precision = 10, int $scale = 0): FluidColumnOptions
6869
{
69-
$this->column->setType(Type::getType(Type::DECIMAL));
70+
$this->column->setType(Type::getType(Types::DECIMAL));
7071
$this->column->setPrecision($precision);
7172
$this->column->setScale($scale);
7273
return $this->getOptions();
7374
}
7475

7576
public function float(int $precision = 10, int $scale = 0): FluidColumnOptions
7677
{
77-
$this->column->setType(Type::getType(Type::FLOAT));
78+
$this->column->setType(Type::getType(Types::FLOAT));
7879
$this->column->setPrecision($precision);
7980
$this->column->setScale($scale);
8081
return $this->getOptions();
8182
}
8283

8384
public function string(?int $length = null, bool $fixed = false): FluidColumnOptions
8485
{
85-
$this->column->setType(Type::getType(Type::STRING));
86+
$this->column->setType(Type::getType(Types::STRING));
8687
$this->column->setLength($length);
8788
$this->column->setFixed($fixed);
8889
return $this->getOptions();
8990
}
9091

9192
public function text(?int $length = null): FluidColumnOptions
9293
{
93-
$this->column->setType(Type::getType(Type::TEXT));
94+
$this->column->setType(Type::getType(Types::TEXT));
9495
$this->column->setLength($length);
9596
return $this->getOptions();
9697
}
9798

9899
public function guid(): FluidColumnOptions
99100
{
100-
$this->column->setType(Type::getType(Type::GUID));
101+
$this->column->setType(Type::getType(Types::GUID));
101102
return $this->getOptions();
102103
}
103104

@@ -106,93 +107,96 @@ public function guid(): FluidColumnOptions
106107
*/
107108
public function binary(?int $length = null, bool $fixed = false): FluidColumnOptions
108109
{
109-
$this->column->setType(Type::getType(Type::BINARY));
110+
$this->column->setType(Type::getType(Types::BINARY));
110111
$this->column->setLength($length);
111112
$this->column->setFixed($fixed);
112113
return $this->getOptions();
113114
}
114115

115116
public function blob(): FluidColumnOptions
116117
{
117-
$this->column->setType(Type::getType(Type::BLOB));
118+
$this->column->setType(Type::getType(Types::BLOB));
118119
return $this->getOptions();
119120
}
120121

121122
public function boolean(): FluidColumnOptions
122123
{
123-
$this->column->setType(Type::getType(Type::BOOLEAN));
124+
$this->column->setType(Type::getType(Types::BOOLEAN));
124125
return $this->getOptions();
125126
}
126127

127128
public function date(): FluidColumnOptions
128129
{
129-
$this->column->setType(Type::getType(Type::DATE));
130+
$this->column->setType(Type::getType(Types::DATE_MUTABLE));
130131
return $this->getOptions();
131132
}
132133

133134
public function dateImmutable(): FluidColumnOptions
134135
{
135-
$this->column->setType(Type::getType(Type::DATE_IMMUTABLE));
136+
$this->column->setType(Type::getType(Types::DATE_IMMUTABLE));
136137
return $this->getOptions();
137138
}
138139

139140
public function datetime(): FluidColumnOptions
140141
{
141-
$this->column->setType(Type::getType(Type::DATETIME));
142+
$this->column->setType(Type::getType(Types::DATETIME_MUTABLE));
142143
return $this->getOptions();
143144
}
144145

145146
public function datetimeImmutable(): FluidColumnOptions
146147
{
147-
$this->column->setType(Type::getType(Type::DATETIME_IMMUTABLE));
148+
$this->column->setType(Type::getType(Types::DATETIME_IMMUTABLE));
148149
return $this->getOptions();
149150
}
150151

151152
public function datetimeTz(): FluidColumnOptions
152153
{
153-
$this->column->setType(Type::getType(Type::DATETIMETZ));
154+
$this->column->setType(Type::getType(Types::DATETIMETZ_MUTABLE));
154155
return $this->getOptions();
155156
}
156157

157158
public function datetimeTzImmutable(): FluidColumnOptions
158159
{
159-
$this->column->setType(Type::getType(Type::DATETIMETZ_IMMUTABLE));
160+
$this->column->setType(Type::getType(Types::DATETIMETZ_IMMUTABLE));
160161
return $this->getOptions();
161162
}
162163

163164
public function time(): FluidColumnOptions
164165
{
165-
$this->column->setType(Type::getType(Type::TIME));
166+
$this->column->setType(Type::getType(Types::TIME_MUTABLE));
166167
return $this->getOptions();
167168
}
168169

169170
public function timeImmutable(): FluidColumnOptions
170171
{
171-
$this->column->setType(Type::getType(Type::TIME_IMMUTABLE));
172+
$this->column->setType(Type::getType(Types::TIME_IMMUTABLE));
172173
return $this->getOptions();
173174
}
174175

175176
public function dateInterval(): FluidColumnOptions
176177
{
177-
$this->column->setType(Type::getType(Type::DATEINTERVAL));
178+
$this->column->setType(Type::getType(Types::DATEINTERVAL));
178179
return $this->getOptions();
179180
}
180181

182+
/**
183+
* @depracated Use json() instead
184+
*/
181185
public function array(): FluidColumnOptions
182186
{
183-
$this->column->setType(Type::getType(Type::TARRAY));
187+
$this->column->setType(Type::getType(Types::ARRAY));
184188
return $this->getOptions();
185189
}
186190

187191
public function simpleArray(): FluidColumnOptions
188192
{
189-
$this->column->setType(Type::getType(Type::SIMPLE_ARRAY));
193+
$this->column->setType(Type::getType(Types::SIMPLE_ARRAY));
190194
return $this->getOptions();
191195
}
192196

193197
public function json(): FluidColumnOptions
194198
{
195-
$this->column->setType(Type::getType(Type::JSON));
199+
$this->column->setType(Type::getType(Types::JSON));
196200
return $this->getOptions();
197201
}
198202

@@ -202,13 +206,16 @@ public function json(): FluidColumnOptions
202206
*/
203207
public function jsonArray(): FluidColumnOptions
204208
{
205-
$this->column->setType(Type::getType(Type::JSON_ARRAY));
209+
$this->column->setType(Type::getType(Types::JSON));
206210
return $this->getOptions();
207211
}
208212

213+
/**
214+
* @depracated Use json() instead
215+
*/
209216
public function object(): FluidColumnOptions
210217
{
211-
$this->column->setType(Type::getType(Type::OBJECT));
218+
$this->column->setType(Type::getType(Types::OBJECT));
212219
return $this->getOptions();
213220
}
214221

@@ -218,7 +225,7 @@ public function references(string $tableName, ?string $constraintName = null, st
218225

219226
$table = $this->fluidSchema->getDbalSchema()->getTable($tableName);
220227

221-
$referencedColumns = $table->getPrimaryKeyColumns();
228+
$referencedColumns = $table->getPrimaryKey()->getColumns();
222229

223230
if (count($referencedColumns) > 1) {
224231
throw new FluidSchemaException('You cannot reference a table with a primary key on several columns using FluidSchema. Use DBAL Schema methods instead.');

src/FluidTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function extends(string $tableName): FluidTable
118118

119119
$inheritedTable = $this->schema->getDbalSchema()->getTable($tableName);
120120

121-
$pks = $inheritedTable->getPrimaryKeyColumns();
121+
$pks = $inheritedTable->getPrimaryKey()->getColumns();
122122

123123
if (count($pks) > 1) {
124124
throw new FluidSchemaException('You cannot inherit from a table with a primary key on several columns using FluidSchema. Use DBAL Schema methods instead.');

0 commit comments

Comments
 (0)