Fixes #2333 exception on comparison with missing id. (master)

Issue also happening on master branch.