-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use COALESCE in having condition
- Loading branch information
Jon Waldstein
committed
Nov 27, 2023
1 parent
c719922
commit b518edf
Showing
1 changed file
with
1 addition
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,13 +276,7 @@ private function getWhereConditions(QueryBuilder $query): array | |
} | ||
|
||
if ($hasWhereConditions) { | ||
if ($testMode){ | ||
$query->having( | ||
'give_donationmeta_attach_meta_mode.meta_value', | ||
'=', | ||
DonationMode::TEST | ||
); | ||
} | ||
$query->havingRaw('HAVING COALESCE(give_donationmeta_attach_meta_mode.meta_value, %s) = %s', DonationMode::LIVE, $testMode ? DonationMode::TEST : DonationMode::LIVE); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JasonTheAdams
Contributor
|
||
} elseif ($testMode) { | ||
$query->where('give_donationmeta_attach_meta_mode.meta_value', DonationMode::TEST); | ||
} else { | ||
|
@jonwaldstein
havingRaw
should still handle adding theHAVING
keyword, otherwise it risks breaking chaining.