Fixed empty where clause issue in relationship search