Added debug logging for getPrimaryField