Skip to content

Commit fbcf644

Browse files
committed
Remove PARTIAL syntax in DQL
1 parent 5a46917 commit fbcf644

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ All notable changes to `omines\datatables-bundle` will be documented in this fil
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [Unreleased]
6-
Nothing yet.
6+
### Added
7+
- Support Doctrine ORM 3 and DBAL 4
8+
9+
### Breaking
10+
- Remove support for partial DQL queries in `AutomaticQueryBuilder`
711

812
## [0.8.2] - 2024-03-24
913
### Added

composer.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@
3535
"ext-zip": "*",
3636
"doctrine/common": "^3.4.3",
3737
"doctrine/doctrine-bundle": "^2.12.0",
38-
"doctrine/orm": "^2.19.3",
38+
"doctrine/orm": "^2.19.3|^3.1.0",
3939
"doctrine/persistence": "^3.3.2",
4040
"friendsofphp/php-cs-fixer": "^3.52.1",
4141
"mongodb/mongodb": "^1.17.1",
4242
"ocramius/package-versions": "^2.8",
4343
"openspout/openspout": "^4.23",
44-
"phpoffice/phpspreadsheet": "^1.29.0 || ^2.0",
44+
"phpoffice/phpspreadsheet": "^1.29.0|^2.0",
4545
"phpstan/extension-installer": "^1.3.1",
4646
"phpstan/phpstan": "^1.10.65",
4747
"phpstan/phpstan-doctrine": "^1.3.64",
4848
"phpstan/phpstan-phpunit": "^1.3.16",
4949
"phpstan/phpstan-symfony": "^1.3.9",
50-
"phpunit/phpunit": "^10.5.10 || ^11.0.8",
50+
"phpunit/phpunit": "^10.5.10|^11.0.8",
5151
"ruflin/elastica": "^6.2|^7.3.2",
5252
"symfony/browser-kit": "^6.3|^7.0.3",
5353
"symfony/css-selector": "^6.3|^7.0.3",
@@ -60,6 +60,11 @@
6060
"symfony/var-dumper": "^6.3|^7.0.4",
6161
"symfony/yaml": "^6.3|^7.0.3"
6262
},
63+
"conflict": {
64+
"doctrine/dbal": "<3 >=5",
65+
"doctrine/orm": "<2.8 >=4",
66+
"elasticsearch/elasticsearch": ">=9"
67+
},
6368
"suggest": {
6469
"doctrine/doctrine-bundle": "For integrated access to Doctrine object managers",
6570
"doctrine/orm": "For full automated integration with Doctrine entities",
@@ -84,7 +89,7 @@
8489
},
8590
"extra": {
8691
"branch-alias": {
87-
"dev-master": "0.8-dev"
92+
"dev-master": "0.9-dev"
8893
}
8994
}
9095
}

src/Adapter/Doctrine/FetchJoinORMAdapter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ protected function getSimpleTotalCount(QueryBuilder $queryBuilder): int
142142
/** @var Query\Expr\From $from_expr */
143143
$from_expr = $queryBuilder->getDQLPart('from')[0];
144144

145-
/* @phpstan-ignore-next-line Unable to determine repository type */
146145
return $this->manager->getRepository($from_expr->getFrom())->count([]);
147146
}
148147
}

src/Adapter/Doctrine/ORM/AutomaticQueryBuilder.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
class AutomaticQueryBuilder implements QueryBuilderProcessorInterface
2727
{
28+
private const DEFAULT_ALIAS = 'entity';
29+
2830
private EntityManagerInterface $em;
2931
private ClassMetadata $metadata;
3032
private string $entityShortName;
@@ -44,7 +46,7 @@ public function __construct(EntityManagerInterface $em, ClassMetadata $metadata)
4446
$this->metadata = $metadata;
4547

4648
$this->entityName = $this->metadata->getName();
47-
$this->entityShortName = mb_strtolower($this->metadata->getReflectionClass()->getShortName());
49+
$this->entityShortName = mb_strtolower($this->metadata->getReflectionClass()?->getShortName() ?? self::DEFAULT_ALIAS);
4850
}
4951

5052
public function process(QueryBuilder $builder, DataTableState $state): void
@@ -135,11 +137,7 @@ private function setIdentifierFromAssociation(string $association, string $key,
135137
private function setSelectFrom(QueryBuilder $qb): void
136138
{
137139
foreach ($this->selectColumns as $key => $value) {
138-
if (false === empty($key)) {
139-
$qb->addSelect('partial ' . $key . '.{' . implode(',', $value) . '}');
140-
} else {
141-
$qb->addSelect($value);
142-
}
140+
$qb->addSelect($key ?: $value);
143141
}
144142
}
145143

src/Adapter/Doctrine/ORMAdapter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ protected function getAliases(AdapterQuery $query): array
130130

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

0 commit comments

Comments
 (0)