From a0adc207de6b4c8f78ac4b16ecfc791e6d592178 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Tue, 17 May 2022 11:25:04 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#1567 --- wire/core/PageFinder.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wire/core/PageFinder.php b/wire/core/PageFinder.php index 125608fe..40d64cbe 100644 --- a/wire/core/PageFinder.php +++ b/wire/core/PageFinder.php @@ -2115,8 +2115,15 @@ class PageFinder extends Wire { // non-presence of row is equal to value being blank $bindKey = $query->bindValueGetKey($blankValue); if($ft->isEmptyValue($field, $value)) { + // matching an empty value: null or literal empty value $sql = "$tableAlias.$col IS NULL OR ($tableAlias.$col=$bindKey"; + if($value === '' && !$ft->isEmptyValue($field, '0') && $field->get('zeroNotEmpty')) { + // MySQL blank string will also match zero (0) in some cases, so we prevent that here + // @todo remove the 'zeroNotEmpty' condition for test on dev as it limits to specific fieldtypes is likely unnecessary + $sql .= " AND $tableAlias.$col!='0'"; + } } else { + // matching a non-empty value $sql = "($tableAlias.$col=$bindKey"; } /*