fix for postgresql + activerecord 2.3

The code was mistakenly using defined? instead of method_defined?, and
the postgres adapter in AR 2.3 doesn't define a exec_query method, so
the alias_method was exploding.

I'm not sure how to write a useful test for this, since the tests always run under (and the gemspec requires) activerecord '< 3.3'