Fixes #2333 exception on comparison with missing id.