From 398b63386393cd11a0a154e9a469ffc483d61aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Jun 2023 23:29:18 +0200 Subject: [PATCH] DX: simplify overlapsI expression in postgresql --- .changes/unreleased/DX-20230614-233000.yaml | 5 +++++ src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/DX-20230614-233000.yaml diff --git a/.changes/unreleased/DX-20230614-233000.yaml b/.changes/unreleased/DX-20230614-233000.yaml new file mode 100644 index 000000000..ca4a3171b --- /dev/null +++ b/.changes/unreleased/DX-20230614-233000.yaml @@ -0,0 +1,5 @@ +kind: DX +body: 'DQL function OVERLAPSI: simplify expression in postgresql' +time: 2023-06-14T23:30:00.217427234+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php index 29642dc15..d39c1451c 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php @@ -90,16 +90,14 @@ class OverlapsI extends FunctionNode if ($part instanceof PathExpression) { return sprintf( - "CASE WHEN %s IS NOT NULL THEN %s ELSE '%s'::date END", - $part->dispatch($sqlWalker), + "COALESCE(%s, '%s'::date)", $part->dispatch($sqlWalker), $p ); } return sprintf( - "CASE WHEN %s::date IS NOT NULL THEN %s::date ELSE '%s'::date END", - $part->dispatch($sqlWalker), + "COALESCE(%s::date, '%s'::date)", $part->dispatch($sqlWalker), $p );