Skip to content

Commit

Permalink
Remove PARTIAL syntax in DQL
Browse files Browse the repository at this point in the history
  • Loading branch information
curry684 committed Apr 11, 2024
1 parent 5a46917 commit fbcf644
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ All notable changes to `omines\datatables-bundle` will be documented in this fil
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
Nothing yet.
### Added
- Support Doctrine ORM 3 and DBAL 4

### Breaking
- Remove support for partial DQL queries in `AutomaticQueryBuilder`

## [0.8.2] - 2024-03-24
### Added
Expand Down
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@
"ext-zip": "*",
"doctrine/common": "^3.4.3",
"doctrine/doctrine-bundle": "^2.12.0",
"doctrine/orm": "^2.19.3",
"doctrine/orm": "^2.19.3|^3.1.0",
"doctrine/persistence": "^3.3.2",
"friendsofphp/php-cs-fixer": "^3.52.1",
"mongodb/mongodb": "^1.17.1",
"ocramius/package-versions": "^2.8",
"openspout/openspout": "^4.23",
"phpoffice/phpspreadsheet": "^1.29.0 || ^2.0",
"phpoffice/phpspreadsheet": "^1.29.0|^2.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.65",
"phpstan/phpstan-doctrine": "^1.3.64",
"phpstan/phpstan-phpunit": "^1.3.16",
"phpstan/phpstan-symfony": "^1.3.9",
"phpunit/phpunit": "^10.5.10 || ^11.0.8",
"phpunit/phpunit": "^10.5.10|^11.0.8",
"ruflin/elastica": "^6.2|^7.3.2",
"symfony/browser-kit": "^6.3|^7.0.3",
"symfony/css-selector": "^6.3|^7.0.3",
Expand All @@ -60,6 +60,11 @@
"symfony/var-dumper": "^6.3|^7.0.4",
"symfony/yaml": "^6.3|^7.0.3"
},
"conflict": {
"doctrine/dbal": "<3 >=5",
"doctrine/orm": "<2.8 >=4",
"elasticsearch/elasticsearch": ">=9"
},
"suggest": {
"doctrine/doctrine-bundle": "For integrated access to Doctrine object managers",
"doctrine/orm": "For full automated integration with Doctrine entities",
Expand All @@ -84,7 +89,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.8-dev"
"dev-master": "0.9-dev"
}
}
}
1 change: 0 additions & 1 deletion src/Adapter/Doctrine/FetchJoinORMAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ protected function getSimpleTotalCount(QueryBuilder $queryBuilder): int
/** @var Query\Expr\From $from_expr */
$from_expr = $queryBuilder->getDQLPart('from')[0];

/* @phpstan-ignore-next-line Unable to determine repository type */
return $this->manager->getRepository($from_expr->getFrom())->count([]);
}
}
10 changes: 4 additions & 6 deletions src/Adapter/Doctrine/ORM/AutomaticQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
class AutomaticQueryBuilder implements QueryBuilderProcessorInterface
{
private const DEFAULT_ALIAS = 'entity';

private EntityManagerInterface $em;
private ClassMetadata $metadata;
private string $entityShortName;
Expand All @@ -44,7 +46,7 @@ public function __construct(EntityManagerInterface $em, ClassMetadata $metadata)
$this->metadata = $metadata;

$this->entityName = $this->metadata->getName();
$this->entityShortName = mb_strtolower($this->metadata->getReflectionClass()->getShortName());
$this->entityShortName = mb_strtolower($this->metadata->getReflectionClass()?->getShortName() ?? self::DEFAULT_ALIAS);
}

public function process(QueryBuilder $builder, DataTableState $state): void
Expand Down Expand Up @@ -135,11 +137,7 @@ private function setIdentifierFromAssociation(string $association, string $key,
private function setSelectFrom(QueryBuilder $qb): void
{
foreach ($this->selectColumns as $key => $value) {
if (false === empty($key)) {
$qb->addSelect('partial ' . $key . '.{' . implode(',', $value) . '}');
} else {
$qb->addSelect($value);
}
$qb->addSelect($key ?: $value);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/Adapter/Doctrine/ORMAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ protected function getAliases(AdapterQuery $query): array

/** @var Query\Expr\From $from */
foreach ($builder->getDQLPart('from') as $from) {
/* @phpstan-ignore-next-line */
$aliases[$from->getAlias()] = [null, $this->manager->getMetadataFactory()->getMetadataFor($from->getFrom())];
}

Expand Down

0 comments on commit fbcf644

Please sign in to comment.