Skip to content

Commit

Permalink
Merge pull request #12 from aszenz/master
Browse files Browse the repository at this point in the history
deps: Upgrade to dbal v3
  • Loading branch information
moufmouf committed Jan 27, 2024
2 parents 343a3f0 + 0200aaf commit d7155ca
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 80 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,54 @@
name: "Continuous Integration"

on:
pull_request:
push:
branches:
- master
jobs:
test:
name: "Test"
runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
# PHPUnit v10 needs PHP 8.1, hence no way to test on older php versions
- "8.1"
- "8.2"
- "8.3"
dependencies:
- "lowest"
- "highest"
exclude:
# Exclude lowest deps version as they don't support newer php versions
- dependencies: "lowest"
php-version: "8.3"
- dependencies: "lowest"
php-version: "8.2"
- dependencies: "lowest"
php-version: "8.1"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "xdebug"
php-version: "${{ matrix.php-version }}"
ini-values: "zend.assertions=1"

- uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c phpunit.xml.dist"

- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
/vendor/
/composer.lock
/build/
/phpunit.xml
/phpunit.xml
.phpunit.result.cache
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -9,13 +9,13 @@
}
],
"require": {
"php": ">=7.1",
"doctrine/dbal": "^2.3",
"php": "^7.4 || ^8.0",
"doctrine/dbal": "^3.0",
"doctrine/inflector": "^1.0 || ^2.0"
},
"require-dev": {
"phpunit/phpunit": "^10.2",
"satooshi/php-coveralls": "^1.0"
"php-coveralls/php-coveralls": "^2.0.0"
},
"autoload": {
"psr-4": {
Expand Down
59 changes: 33 additions & 26 deletions src/FluidColumn.php
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

class FluidColumn
{
Expand Down Expand Up @@ -48,56 +49,56 @@ public function __construct(FluidSchema $fluidSchema, FluidTable $fluidTable, Ta

public function integer(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::INTEGER));
$this->column->setType(Type::getType(Types::INTEGER));
return $this->getOptions();
}

public function smallInt(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::SMALLINT));
$this->column->setType(Type::getType(Types::SMALLINT));
return $this->getOptions();
}

public function bigInt(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::BIGINT));
$this->column->setType(Type::getType(Types::BIGINT));
return $this->getOptions();
}

public function decimal(int $precision = 10, int $scale = 0): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::DECIMAL));
$this->column->setType(Type::getType(Types::DECIMAL));
$this->column->setPrecision($precision);
$this->column->setScale($scale);
return $this->getOptions();
}

public function float(int $precision = 10, int $scale = 0): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::FLOAT));
$this->column->setType(Type::getType(Types::FLOAT));
$this->column->setPrecision($precision);
$this->column->setScale($scale);
return $this->getOptions();
}

public function string(?int $length = null, bool $fixed = false): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::STRING));
$this->column->setType(Type::getType(Types::STRING));
$this->column->setLength($length);
$this->column->setFixed($fixed);
return $this->getOptions();
}

public function text(?int $length = null): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::TEXT));
$this->column->setType(Type::getType(Types::TEXT));
$this->column->setLength($length);
return $this->getOptions();
}

public function guid(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::GUID));
$this->column->setType(Type::getType(Types::GUID));
return $this->getOptions();
}

Expand All @@ -106,93 +107,96 @@ public function guid(): FluidColumnOptions
*/
public function binary(?int $length = null, bool $fixed = false): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::BINARY));
$this->column->setType(Type::getType(Types::BINARY));
$this->column->setLength($length);
$this->column->setFixed($fixed);
return $this->getOptions();
}

public function blob(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::BLOB));
$this->column->setType(Type::getType(Types::BLOB));
return $this->getOptions();
}

public function boolean(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::BOOLEAN));
$this->column->setType(Type::getType(Types::BOOLEAN));
return $this->getOptions();
}

public function date(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::DATE));
$this->column->setType(Type::getType(Types::DATE_MUTABLE));
return $this->getOptions();
}

public function dateImmutable(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::DATE_IMMUTABLE));
$this->column->setType(Type::getType(Types::DATE_IMMUTABLE));
return $this->getOptions();
}

public function datetime(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::DATETIME));
$this->column->setType(Type::getType(Types::DATETIME_MUTABLE));
return $this->getOptions();
}

public function datetimeImmutable(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::DATETIME_IMMUTABLE));
$this->column->setType(Type::getType(Types::DATETIME_IMMUTABLE));
return $this->getOptions();
}

public function datetimeTz(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::DATETIMETZ));
$this->column->setType(Type::getType(Types::DATETIMETZ_MUTABLE));
return $this->getOptions();
}

public function datetimeTzImmutable(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::DATETIMETZ_IMMUTABLE));
$this->column->setType(Type::getType(Types::DATETIMETZ_IMMUTABLE));
return $this->getOptions();
}

public function time(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::TIME));
$this->column->setType(Type::getType(Types::TIME_MUTABLE));
return $this->getOptions();
}

public function timeImmutable(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::TIME_IMMUTABLE));
$this->column->setType(Type::getType(Types::TIME_IMMUTABLE));
return $this->getOptions();
}

public function dateInterval(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::DATEINTERVAL));
$this->column->setType(Type::getType(Types::DATEINTERVAL));
return $this->getOptions();
}

/**
* @depracated Use json() instead
*/
public function array(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::TARRAY));
$this->column->setType(Type::getType(Types::ARRAY));
return $this->getOptions();
}

public function simpleArray(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::SIMPLE_ARRAY));
$this->column->setType(Type::getType(Types::SIMPLE_ARRAY));
return $this->getOptions();
}

public function json(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::JSON));
$this->column->setType(Type::getType(Types::JSON));
return $this->getOptions();
}

Expand All @@ -202,13 +206,16 @@ public function json(): FluidColumnOptions
*/
public function jsonArray(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::JSON_ARRAY));
$this->column->setType(Type::getType(Types::JSON));
return $this->getOptions();
}

/**
* @depracated Use json() instead
*/
public function object(): FluidColumnOptions
{
$this->column->setType(Type::getType(Type::OBJECT));
$this->column->setType(Type::getType(Types::OBJECT));
return $this->getOptions();
}

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

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

$referencedColumns = $table->getPrimaryKeyColumns();
$referencedColumns = $table->getPrimaryKey()->getColumns();

if (count($referencedColumns) > 1) {
throw new FluidSchemaException('You cannot reference a table with a primary key on several columns using FluidSchema. Use DBAL Schema methods instead.');
Expand Down
2 changes: 1 addition & 1 deletion src/FluidTable.php
Expand Up @@ -118,7 +118,7 @@ public function extends(string $tableName): FluidTable

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

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

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

0 comments on commit d7155ca

Please sign in to comment.