There is probably a more elegant solution but this works well enough for now.
Used callbacks to enable sqlite to perform cnecessary calculations.
These tests can't pass since the code it tests is not fully ported to Rails 3
Some tests are passing. Some are not passing yet : - when using where() later in the chain - when using the associations or includes
The core method is OK and some utility methods are OK too. We have to remake the "substitute_distance_in_where" method