Fix "cant modify frozen object" on PG adapters

I believe this is very similar to https://github.com/MiniProfiler/rack-mini-profiler/pull/49
it's trying to modify a nil object so we better check for nil before
setting the instance var

I've been enjoying working on Spree with rack mini profiler installed but for some reason I started getting those errors today, probably some internal spree query change. Got that running on rails 4.0.3