Depth buffer in equirectangular projection returns Euclidian distance and not Z depth. Is it possible to get Z depth?

Hello, I am trying to get the depth buffer using Cycles. Here, I define it as the z component of distance away from the pinhole camera (and not as the Euclidian distance sqrt(x^2+y^2+z^2)). I tried Cycles Perspective projection and saved the depth node to an openexr file. It gave the correct values for a simple example of a cube in front of the camera. All of cube was at the same depth.

However, switching to Equirectangular projection, and repeating the same steps, the depth buffer seemed to contain the Euclidian distance (i.e. the cube was not flat anymore, parts further from the camera had higher depth values). Is there a way to get a Z component of the depth buffer in the Equirectangular projection case?

Thanks a lot for the help