From 23a57f3b76dfd0b0b570046b2f79d0db548648df Mon Sep 17 00:00:00 2001 From: Johan Vervloet Date: Thu, 15 Jun 2017 21:51:04 +0200 Subject: [PATCH] CRM-20740 - Fix issue with check for custom_nn => ['IS NULL' => 1]. --- Civi/API/Api3SelectQuery.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Civi/API/Api3SelectQuery.php b/Civi/API/Api3SelectQuery.php index 1585b152b1..bb3f458ebc 100644 --- a/Civi/API/Api3SelectQuery.php +++ b/Civi/API/Api3SelectQuery.php @@ -89,7 +89,10 @@ class Api3SelectQuery extends SelectQuery { $column_name = $key; } elseif (($cf_id = \CRM_Core_BAO_CustomField::getKeyID($key)) != FALSE) { - list($table_name, $column_name) = $this->addCustomField($this->apiFieldSpec['custom_' . $cf_id], 'INNER'); + // If we check a custom field on 'IS NULL', it should also work when there is no + // record in the custom value table, see CRM-20740. + $side = empty($value['IS NULL']) ? 'INNER': 'LEFT OUTER'; + list($table_name, $column_name) = $this->addCustomField($this->apiFieldSpec['custom_' . $cf_id], $side); } elseif (strpos($key, '.')) { $fkInfo = $this->addFkField($key, 'INNER'); -- 2.25.1