Fixes #2333 exception on comparison with missing id.

Quick fix for #2333.