mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-04 05:44:58 +00:00
GenericDoc: add provider for AccompanyingCourseDocument, without filtering
This commit is contained in:
@@ -11,20 +11,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\GenericDoc;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
|
||||
final readonly class FetchQueryToSqlBuilder
|
||||
{
|
||||
private const SQL = <<<'SQL'
|
||||
SELECT
|
||||
'{{ key }}' AS key,
|
||||
{{ identifiers }} AS identifiers,
|
||||
{{ date }} AS doc_date
|
||||
{{ date }}::date AS doc_date
|
||||
FROM {{ from }}
|
||||
WHERE {{ where }}
|
||||
{{ where }}
|
||||
SQL;
|
||||
|
||||
/**
|
||||
* @param FetchQueryInterface $query
|
||||
* @return array{sql: string, params: list<mixed>}
|
||||
* @return array{sql: string, params: list<mixed>, types: list<Types::*>}
|
||||
*/
|
||||
public function toSql(FetchQueryInterface $query): array
|
||||
{
|
||||
@@ -33,7 +35,7 @@ final readonly class FetchQueryToSqlBuilder
|
||||
'{{ identifiers }}' => $query->getSelectIdentifierJsonB(),
|
||||
'{{ date }}' => $query->getSelectDate(),
|
||||
'{{ from }}' => $query->getFromQuery(),
|
||||
'{{ where }}' => $query->getWhereQuery(),
|
||||
'{{ where }}' => '' === ($w = $query->getWhereQuery()) ? '' : 'WHERE ' . $w,
|
||||
]);
|
||||
|
||||
$params = [
|
||||
@@ -43,6 +45,13 @@ final readonly class FetchQueryToSqlBuilder
|
||||
...$query->getWhereQueryParams()
|
||||
];
|
||||
|
||||
return ['sql' => $sql, 'params' => $params];
|
||||
$types = [
|
||||
...$query->getSelectIdentifiersTypes(),
|
||||
...$query->getSelectDateTypes(),
|
||||
...$query->getFromQueryTypes(),
|
||||
...$query->getWhereQueryTypes(),
|
||||
];
|
||||
|
||||
return ['sql' => $sql, 'params' => $params, 'types' => $types];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user