From 8e045ef8919d5ea2b3386af4ae7b5b4d02ebb55e Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 13 Jan 2024 07:47:33 +0000 Subject: [PATCH] fix: update org users search query --- packages/nocodb/src/models/User.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/models/User.ts b/packages/nocodb/src/models/User.ts index a03e5c736e..3db162846a 100644 --- a/packages/nocodb/src/models/User.ts +++ b/packages/nocodb/src/models/User.ts @@ -229,7 +229,25 @@ export default class User implements UserType { .as('projectsCount'), ); if (query) { - queryBuilder.where('email', 'like', `%${query.toLowerCase?.()}%`); + queryBuilder + .where(function () { + this.where('email', 'like', `%${query.toLowerCase?.()}%`).orWhere( + 'display_name', + 'like', + `%${query.toLowerCase?.()}%`, + ); + }) + .where(function () { + this.where(function () { + this.whereNotNull('display_name') + .andWhereNot('display_name', '') + .andWhere('display_name', 'like', `%${query.toLowerCase?.()}%`); + }).orWhere(function () { + this.whereNull('display_name') + .orWhere('display_name', '') + .andWhere('email', 'like', `%${query.toLowerCase?.()}%`); + }); + }); } return queryBuilder;