Skip to content

Commit

Permalink
Support Doctrine DBAL 4, drop support for version 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed Feb 8, 2024
1 parent a767a1e commit 89fd916
Show file tree
Hide file tree
Showing 31 changed files with 132 additions and 310 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ jobs:
- name: "Test"
run: "composer test"
env:
PGSQL_DATABASE_URL: postgresql://postgres:[email protected]:${{ job.services.postgres.ports[5432] }}/postgres?serverVersion=11&charset=utf8
PGSQL_DATABASE_URL: pgsql://postgres:[email protected]:${{ job.services.postgres.ports[5432] }}/postgres?serverVersion=11&charset=utf8
MYSQL_DATABASE_URL: mysql://mysql:[email protected]:${{ job.services.mysql.ports[3306] }}/mysql
FLOW_LOCAL_FILESYSTEM_CACHE_DIR: "./var/cache/${{ matrix.php-version }}-${{ matrix.dependencies }}"

- name: "Run Examples"
run: "php examples/run.php"
run: "php examples/run.php"
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"ext-zlib": "*",
"composer-runtime-api": "^2.1",
"coduo/php-humanizer": "^4.0",
"doctrine/dbal": "^3.6",
"doctrine/dbal": "^4.0",
"elasticsearch/elasticsearch": "^7.6|^8.0",
"flix-tech/avro-php": "~4.2.0 || ~4.3.0",
"google/apiclient": "^2.13",
Expand Down
219 changes: 15 additions & 204 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</report>
</coverage>
<php>
<env name="PGSQL_DATABASE_URL" value="postgresql://postgres:[email protected]:5432/postgres?serverVersion=11%26charset=utf8"/>
<env name="PGSQL_DATABASE_URL" value="pgsql://postgres:[email protected]:5432/postgres?serverVersion=11%26charset=utf8"/>
<env name="MYSQL_DATABASE_URL" value="mysql://mysql:[email protected]:3306/mysql"/>
<env name="SQLITE_DATABASE_URL" value="sqlite:///:memory:"/>
<env name="ELASTICSEARCH_URL" value="localhost:9200"/>
Expand Down
1 change: 1 addition & 0 deletions src/adapter/etl-adapter-doctrine/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
],
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"doctrine/dbal": "^4.0",
"flow-php/doctrine-dbal-bulk": "^0.5.0 || 1.x-dev",
"flow-php/etl": "^0.5.0 || 1.x-dev"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function from(Rows $rows) : DataFrame
}
}

/** @psalm-suppress InvalidArgument */
return (new Flow())->extract(\Flow\ETL\Adapter\Doctrine\dbal_from_query($this->connection(), $this->query, $parameters, $types));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function table(
}

$queryBuilder = $connection->createQueryBuilder()
->select($table->columns ?: '*')
->select(...$table->columns ?: ['*'])
->from($table->name);

foreach ($orderBy as $order) {
Expand All @@ -57,13 +57,7 @@ public function extract(FlowContext $context) : \Generator
$total = $this->maximum;
} else {
$countQuery = (clone $this->queryBuilder)->select('COUNT(*)');

if (\method_exists($countQuery, 'resetOrderBy')) {
$countQuery->resetOrderBy();
} else {
/** @psalm-suppress DeprecatedMethod */
$countQuery->resetQueryPart('orderBy');
}
$countQuery->resetOrderBy();

$total = (int) $this->connection->fetchOne(
$countQuery->getSQL(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
namespace Flow\ETL\Adapter\Doctrine;

use function Flow\ETL\DSL\array_to_rows;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Types\Type;
use Flow\ETL\Extractor;
use Flow\ETL\FlowContext;

final class DbalQueryExtractor implements Extractor
{
/**
* @var ParametersSet
*/
private readonly ParametersSet $parametersSet;

/**
* @param null|ParametersSet $parametersSet
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types
* @param array<int<0, max>|string, ArrayParameterType|ParameterType|string|Type> $types
*/
public function __construct(
private readonly Connection $connection,
Expand All @@ -32,7 +30,7 @@ public function __construct(

/**
* @param array<string, mixed>|list<mixed> $parameters
* @param array<int, null|int|string|Type>|array<string, null|int|string|Type> $types
* @param array<int<0, max>|string, ArrayParameterType|ParameterType|string|Type> $types
*/
public static function single(Connection $connection, string $query, array $parameters = [], array $types = []) : self
{
Expand Down
Loading

0 comments on commit 89fd916

Please sign in to comment.