Consistently use ActiveRecord / Arel APIs to build SQL queries

This brings IDC in line with ActiveRecord when it comes to handling input of the wrong type.

The current behaviour causes mismatching types in the SQL query:
``` ruby
Item.where(associated_id: 'garbage', id: 'garbage').first
# => SELECT * FROM items WHERE associated_id = 0 AND id = 0 LIMIT 1
Item.fetch_by_associated_id_and_id('garbage', 'garbage')
# => SELECT * FROM items WHERE associated_id = 'garbage' AND id = 'garbage' LIMIT 1
```

By piggybacking on the ActiveRecord/Arel query builder API, the WHERE clause will be type aware, and convert the input to the correct type (`input.to_i` => `0`). This is consistent with how ActiveRecord behaves elsewhere.

I also added some `reorder(nil)` calls here and there to prevent useless ORDER clauses to be included in the queries

@fbogsany @camilo @jduff @fw42