Fix build of lookup table for grouped ids

The ODM allows the use of custom types for identifier fields, however it
currently uses the PHP value of an identifier as an array index key for
grouping IDs together. This throws "illegal offset" errors when the PHP value is for example
an object.