In case of existing ids but empty mainkeys it should not create an unfilt...

...ered query