mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
Fix CI: Day/Hour DQL + QueryBuilder::select() for DBAL 4
(cherry picked from commit e20abd232d)
This commit is contained in:
parent
a6972e5ae5
commit
f906fcba7f
3 changed files with 16 additions and 6 deletions
|
|
@ -42,7 +42,7 @@ final class AllTaxons implements AllTaxonsInterface
|
|||
$queryBuilder = $this->entityManager->getConnection()->createQueryBuilder();
|
||||
|
||||
$queryBuilder
|
||||
->select([
|
||||
->select(
|
||||
'taxon.id as id',
|
||||
'taxon.tree_root as tree_root',
|
||||
'taxon.parent_id as parent_id',
|
||||
|
|
@ -53,7 +53,7 @@ final class AllTaxons implements AllTaxonsInterface
|
|||
'taxon.position as position',
|
||||
'taxon.enabled as enabled',
|
||||
'COALESCE(current_translation.name, fallback_translation.name) as name',
|
||||
])
|
||||
)
|
||||
->from('sylius_taxon', 'taxon')
|
||||
->leftJoin(
|
||||
'taxon',
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ namespace Sylius\Bundle\CoreBundle\Doctrine\DQL;
|
|||
|
||||
use Doctrine\DBAL\Platforms\MySQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\AST\Node;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
|
|
@ -49,10 +48,16 @@ final class Day extends FunctionNode
|
|||
return sprintf('EXTRACT(DAY FROM %s)', $sqlWalker->walkArithmeticPrimary($this->date));
|
||||
}
|
||||
|
||||
if (is_a($platform, SqlitePlatform::class, true)) {
|
||||
if ($this->isSqlitePlatform($platform)) {
|
||||
return sprintf('CAST(STRFTIME("%%d", %s) AS NUMBER)', $sqlWalker->walkArithmeticPrimary($this->date));
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf('Platform "%s" is not supported!', get_class($platform)));
|
||||
}
|
||||
|
||||
/** Compatibility layer for DBAL 3.x (SqlitePlatform) and 4.x (SQLitePlatform) */
|
||||
private function isSqlitePlatform(object $platform): bool
|
||||
{
|
||||
return str_contains(get_class($platform), 'SqlitePlatform') || str_contains(get_class($platform), 'SQLitePlatform');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ namespace Sylius\Bundle\CoreBundle\Doctrine\DQL;
|
|||
|
||||
use Doctrine\DBAL\Platforms\MySQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\AST\Node;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
|
|
@ -49,10 +48,16 @@ final class Hour extends FunctionNode
|
|||
return sprintf('EXTRACT(HOUR FROM %s)', $sqlWalker->walkArithmeticPrimary($this->date));
|
||||
}
|
||||
|
||||
if (is_a($platform, SqlitePlatform::class, true)) {
|
||||
if ($this->isSqlitePlatform($platform)) {
|
||||
return sprintf('CAST(STRFTIME("%%H", %s) AS NUMBER)', $sqlWalker->walkArithmeticPrimary($this->date));
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf('Platform "%s" is not supported!', get_class($platform)));
|
||||
}
|
||||
|
||||
/** Compatibility layer for DBAL 3.x (SqlitePlatform) and 4.x (SQLitePlatform) */
|
||||
private function isSqlitePlatform(object $platform): bool
|
||||
{
|
||||
return str_contains(get_class($platform), 'SqlitePlatform') || str_contains(get_class($platform), 'SQLitePlatform');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue