Fix bug with querying by fid

Bug introduced in previous commit.