Only coerce belongsTo ids to string if id is defined

#918 forced coercion of belongTo ids into `String`.  It did not take into account `null` or `undefined` foreign keys (when belongsTo is optional / does not exist).