|
5 | 5 |
|
6 | 6 | use Doctrine\Common\Cache\Cache;
|
7 | 7 | use Doctrine\DBAL\Platforms\MySqlPlatform;
|
| 8 | +use Doctrine\DBAL\Platforms\OraclePlatform; |
8 | 9 | use Doctrine\DBAL\Schema\Schema;
|
9 | 10 | use TheCodingMachine\TDBM\OrderByAnalyzer;
|
10 | 11 | use TheCodingMachine\TDBM\TDBMService;
|
@@ -55,18 +56,22 @@ protected function compute(): void
|
55 | 56 |
|
56 | 57 | $subQuery = 'SELECT DISTINCT '.implode(', ', $pkColumnNames).' FROM MAGICJOIN('.$this->mainTable.')';
|
57 | 58 |
|
| 59 | + if (!empty($this->filterString)) { |
| 60 | + $sql .= ' WHERE '.$this->filterString; |
| 61 | + $subQuery .= ' WHERE '.$this->filterString; |
| 62 | + } |
| 63 | + |
58 | 64 | if (count($pkColumnNames) === 1 || $this->tdbmService->getConnection()->getDatabasePlatform() instanceof MySqlPlatform) {
|
59 | 65 | $countSql = 'SELECT COUNT(DISTINCT '.implode(', ', $pkColumnNames).') FROM MAGICJOIN('.$this->mainTable.')';
|
| 66 | + if (!empty($this->filterString)) { |
| 67 | + $countSql .= ' WHERE '.$this->filterString; |
| 68 | + } |
| 69 | + } elseif ($this->tdbmService->getConnection()->getDatabasePlatform() instanceof OraclePlatform) { |
| 70 | + $countSql = 'SELECT COUNT(*) FROM ('.$subQuery.')'; |
60 | 71 | } else {
|
61 | 72 | $countSql = 'SELECT COUNT(*) FROM ('.$subQuery.') tmp';
|
62 | 73 | }
|
63 | 74 |
|
64 |
| - if (!empty($this->filterString)) { |
65 |
| - $sql .= ' WHERE '.$this->filterString; |
66 |
| - $countSql .= ' WHERE '.$this->filterString; |
67 |
| - $subQuery .= ' WHERE '.$this->filterString; |
68 |
| - } |
69 |
| - |
70 | 75 | if (!empty($orderString)) {
|
71 | 76 | $sql .= ' ORDER BY '.$orderString;
|
72 | 77 | }
|
|
0 commit comments