Account for Relation#maximum returning nil

As thats what its supposed to do by design apparently. The reason this
is working in 4-0-stable (where it returns 0) is probably due to the
ThrowResult logig which was dropped here https://github.com/rails/rails/pull/10561