basecamp / easymon

Easy Monitoring
MIT License
205 stars 16 forks source link

ActiveRecordCheck fails on PostgreSQL #18

Closed oree closed 8 years ago

oree commented 8 years ago

The current ActiveRecordCheck fails on Postgres, because SELECT 1=1 returns true, not 1 as the check expects.

On Postgres:

postgresql=> SELECT 1=1;
 ?column? 
----------
 t
(1 row)

postgresql=> SELECT 1;
 ?column? 
----------
        1
(1 row)

On MySQL:

mysql> SELECT 1=1;
+-----+
| 1=1 |
+-----+
|   1 |
+-----+

1 row in set (0.00 sec)
mysql> SELECT 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

Hence the check at https://github.com/basecamp/easymon/blob/master/lib/easymon/checks/active_record_check.rb#L21 fails on Postgres.

Would you consider changing the check to just SELECT 1, which would work on MySQL, Postgres, SQLite, and probably quite a few others?
Should I submit a pull request for the change?

johnwilliams commented 8 years ago

You are more than welcome to submit a pull request (including tests) and we'll get it merged in.