diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index e08b8982..b2fe7381 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -609,7 +609,11 @@ export class OrganizationController extends Controller { .createQueryBuilder("orgRoot") .where("orgRoot.orgRevisionId = :id", { id }) .andWhere( - _data.root != undefined && _data.root != null ? `orgRoot.id IN (:...node)` : "1=1", + _data.root != undefined && _data.root != null + ? _data.root[0] != null + ? `orgRoot.id IN (:...node)` + : `orgRoot.id is null` + : "1=1", { node: _data.root, }, @@ -638,7 +642,9 @@ export class OrganizationController extends Controller { .where("orgChild1.orgRootId IN (:...ids)", { ids: orgRootIds }) .andWhere( _data.child1 != undefined && _data.child1 != null - ? `orgChild1.id IN (:...node)` + ? _data.child1[0] != null + ? `orgChild1.id IN (:...node)` + : `orgChild1.id is null` : "1=1", { node: _data.child1, @@ -670,7 +676,9 @@ export class OrganizationController extends Controller { .where("orgChild2.orgChild1Id IN (:...ids)", { ids: orgChild1Ids }) .andWhere( _data.child2 != undefined && _data.child2 != null - ? `orgChild2.id IN (:...node)` + ? _data.child2[0] != null + ? `orgChild2.id IN (:...node)` + : `orgChild2.id is null` : "1=1", { node: _data.child2, @@ -703,7 +711,9 @@ export class OrganizationController extends Controller { .where("orgChild3.orgChild2Id IN (:...ids)", { ids: orgChild2Ids }) .andWhere( _data.child3 != undefined && _data.child3 != null - ? `orgChild3.id IN (:...node)` + ? _data.child3[0] != null + ? `orgChild3.id IN (:...node)` + : `orgChild3.id is null` : "1=1", { node: _data.child3, @@ -736,7 +746,9 @@ export class OrganizationController extends Controller { .where("orgChild4.orgChild3Id IN (:...ids)", { ids: orgChild3Ids }) .andWhere( _data.child4 != undefined && _data.child4 != null - ? `orgChild4.id IN (:...node)` + ? _data.child4[0] != null + ? `orgChild4.id IN (:...node)` + : `orgChild4.id is null` : "1=1", { node: _data.child4, @@ -3848,7 +3860,11 @@ export class OrganizationController extends Controller { .createQueryBuilder("orgRoot") .where("orgRoot.orgRevisionId = :id", { id }) .andWhere( - _data.root != undefined && _data.root != null ? `orgRoot.id IN (:...node)` : "1=1", + _data.root != undefined && _data.root != null + ? _data.root[0] != null + ? `orgRoot.id IN (:...node)` + : `orgRoot.id is null` + : "1=1", { node: _data.root, }, @@ -3877,7 +3893,9 @@ export class OrganizationController extends Controller { .where("orgChild1.orgRootId IN (:...ids)", { ids: orgRootIds }) .andWhere( _data.child1 != undefined && _data.child1 != null + ? _data.child1[0] != null ? `orgChild1.id IN (:...node)` + : `orgChild1.id is null` : "1=1", { node: _data.child1, @@ -3909,7 +3927,9 @@ export class OrganizationController extends Controller { .where("orgChild2.orgChild1Id IN (:...ids)", { ids: orgChild1Ids }) .andWhere( _data.child2 != undefined && _data.child2 != null + ? _data.child2[0] != null ? `orgChild2.id IN (:...node)` + : `orgChild2.id is null` : "1=1", { node: _data.child2, @@ -3942,7 +3962,9 @@ export class OrganizationController extends Controller { .where("orgChild3.orgChild2Id IN (:...ids)", { ids: orgChild2Ids }) .andWhere( _data.child3 != undefined && _data.child3 != null + ? _data.child3[0] != null ? `orgChild3.id IN (:...node)` + : `orgChild3.id is null` : "1=1", { node: _data.child3, @@ -3975,7 +3997,9 @@ export class OrganizationController extends Controller { .where("orgChild4.orgChild3Id IN (:...ids)", { ids: orgChild3Ids }) .andWhere( _data.child4 != undefined && _data.child4 != null + ? _data.child4[0] != null ? `orgChild4.id IN (:...node)` + : `orgChild4.id is null` : "1=1", { node: _data.child4, diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 8ed4fd13..31d1c3be 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -2637,42 +2637,42 @@ export class ProfileController extends Controller { .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .andWhere( _data.root != undefined && _data.root != null - ? `current_holders.orgRootId IN (:...root)` + ? (_data.root[0] !=null ? `current_holders.orgRootId = :root` : `current_holders.orgRootId is null`) : "1=1", { - root: _data.root, + root: _data.root[0], }, ) .andWhere( _data.child1 != undefined && _data.child1 != null - ? `current_holders.orgChild1Id IN (:...child1)` + ? (_data.child1[0] !=null ? `current_holders.orgChild1Id = :child1` : `current_holders.orgChild1Id is null`) : "1=1", { - child1: _data.child1, + child1: _data.child1[0], }, ) .andWhere( _data.child2 != undefined && _data.child2 != null - ? `current_holders.orgChild2Id IN (:...child2)` + ? (_data.child2[0] !=null ? `current_holders.orgChild2Id = :child2` : `current_holders.orgChild2Id is null`) : "1=1", { - child2: _data.child2, + child2: _data.child2[0], }, ) .andWhere( _data.child3 != undefined && _data.child3 != null - ? `current_holders.orgChild3Id IN (:...child3)` + ? (_data.child3[0] !=null ? `current_holders.orgChild3Id = :child3` : `current_holders.orgChild3Id is null`) : "1=1", { - child3: _data.child3, + child3: _data.child3[0], }, ) .andWhere( _data.child4 != undefined && _data.child4 != null - ? `current_holders.orgChild4Id IN (:...child4)` + ? (_data.child4[0] !=null ? `current_holders.orgChild4Id = :child4` : `current_holders.orgChild4Id is null`) : "1=1", { - child4: _data.child4, + child4: _data.child4[0], }, ) .andWhere( diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index c2aeb925..ea176399 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1133,42 +1133,52 @@ export class ProfileEmployeeController extends Controller { .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .andWhere( _data.root != undefined && _data.root != null - ? `current_holders.orgRootId IN (:...root)` + ? _data.root[0] != null + ? `current_holders.orgRootId = :root` + : `current_holders.orgRootId is null` : "1=1", { - root: _data.root, + root: _data.root[0], }, ) .andWhere( _data.child1 != undefined && _data.child1 != null - ? `current_holders.orgChild1Id IN (:...child1)` + ? _data.child1[0] != null + ? `current_holders.orgChild1Id = :child1` + : `current_holders.orgChild1Id is null` : "1=1", { - child1: _data.child1, + child1: _data.child1[0], }, ) .andWhere( _data.child2 != undefined && _data.child2 != null - ? `current_holders.orgChild2Id IN (:...child2)` + ? _data.child2[0] != null + ? `current_holders.orgChild2Id = :child2` + : `current_holders.orgChild2Id is null` : "1=1", { - child2: _data.child2, + child2: _data.child2[0], }, ) .andWhere( _data.child3 != undefined && _data.child3 != null - ? `current_holders.orgChild3Id IN (:...child3)` + ? _data.child3[0] != null + ? `current_holders.orgChild3Id = :child3` + : `current_holders.orgChild3Id is null` : "1=1", { - child3: _data.child3, + child3: _data.child3[0], }, ) .andWhere( _data.child4 != undefined && _data.child4 != null - ? `current_holders.orgChild4Id IN (:...child4)` + ? _data.child4[0] != null + ? `current_holders.orgChild4Id = :child4` + : `current_holders.orgChild4Id is null` : "1=1", { - child4: _data.child4, + child4: _data.child4[0], }, ) .andWhere(