Testing Result of raw sql query

I need to be able to catch when my postgresql database returns no rows in a raw sql query. In this case it would be an error indicating that the long and lat are outside of the shape file.

s = Boundary.find_by_sql("SELECT name, country, stateabb FROM boundaries WHERE distance( the_geom,'POINT(#{@lon} #{@lat})') = 0")

testing with s.nil! does not seem to solve the problem

Any ideas?

Here are two queries one without a record and one with

# SELECT name, country, stateabb FROM boundaries WHERE distance( the_geom,'POINT(-89.0 0.0)') = 0; name | country | stateabb

s.empty? ?

-faisal

I would recommend to trace log/development.log to check the actual SQL statement being executed by Rails.