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;