Skip to content

EspoCRM – Open Source CRM Application

Fix person name search

Yurii37a3beb798af
diff --git a/application/Espo/Core/Utils/Database/Orm/FieldConverters/PersonName.php b/application/Espo/Core/Utils/Database/Orm/FieldConverters/PersonName.php
index 30c75eb14b..751e7bfd0a 100644
--- a/application/Espo/Core/Utils/Database/Orm/FieldConverters/PersonName.php
+++ b/application/Espo/Core/Utils/Database/Orm/FieldConverters/PersonName.php
@@ -101,6 +101,12 @@ class PersonName implements FieldConverter
$whereItems[] = "CONCAT:($lastName, ' ', $firstName, ' ', $middleName)";
}
+ $nameColumns = [
+ $firstName . 'A',
+ $middleName,
+ $lastName,
+ ];
+
$selectExpression = $this->getSelect($fullList);
$selectForeignExpression = $this->getSelect($fullList, '{alias}');
@@ -144,6 +150,43 @@ class PersonName implements FieldConverter
'OR' => array_fill_keys($whereItems, '{value}'),
],
],
+ '<>' => [
+ 'whereClause' => [
+ 'AND' => array_fill_keys(
+ array_map(fn ($item) => $item . '!=', $whereItems),
+ '{value}'
+ ),
+ ],
+ ],
+ 'IN' => [
+ // Not supported.
+ 'whereClause' => [
+ 'false:' => null,
+ ]
+ ],
+ 'NOT IN' => [
+ // Not supported.
+ 'whereClause' => [
+ 'false:' => null,
+ ]
+ ],
+ 'IS NULL' => [
+ 'whereClause' => [
+ 'AND' => array_fill_keys(
+ array_map(fn ($item) => $item . '=', $nameColumns),
+ null
+ ),
+ ]
+
+ ],
+ 'IS NOT NULL' => [
+ 'whereClause' => [
+ 'OR' => array_fill_keys(
+ array_map(fn ($item) => $item . '!=', $nameColumns),
+ null
+ ),
+ ]
+ ],
],
'order' => [
'order' => [
diff --git a/client/src/views/fields/person-name.js b/client/src/views/fields/person-name.js
index 9f13e2dfcd..9b35fe5099 100644
--- a/client/src/views/fields/person-name.js
+++ b/client/src/views/fields/person-name.js
@@ -97,6 +97,9 @@ class PersonNameFieldView extends VarcharFieldView {
setup() {
super.setup();
+ this.searchTypeList =
+ this.searchTypeList.filter(it => !['anyOf', 'noneOf'].includes(it));
+
const ucName = Espo.Utils.upperCaseFirst(this.name);
this.salutationField = 'salutation' + ucName;
@@ -255,6 +258,21 @@ class PersonNameFieldView extends VarcharFieldView {
return data;
}
+ fetchSearch() {
+ if (this.fetchSearchType() === 'isNotEmpty') {
+ return {
+ type: 'isNotNull',
+ attribute: this.name,
+ value: null,
+ data: {
+ type: 'isNotEmpty',
+ },
+ };
+ }
+
+ return super.fetchSearch();
+ }
+
/**
* @param {{first?: string, last?: string, middle?: string, salutation?: string}}data
* @return {?string}