Make queries handle null identifiers