clyfe/acts_as_nested_interval — pull request #5 by klobuczek (2012-10-05 23:31:18+00:00)
Title: Another 2 serious bugs with mysql

Found 2 bugs with mysql:

1) @var assignments in where clause are unpredictable in mysql. See: http://beerpla.net/2009/02/17/swapping-column-values-in-mysql/
Even approach 2) still didn't work properly, so I used approach 3). The problem cannot be reproduced with tests. I couldn't make any tests fail. They always pass no matter how the @var is implemented, but our application consistently fails. I guess it depends on how big the data is.

2) The lft and rgt are calculated in 2 different ways in the gem. Most of the time by ruby and in the case of update by the database for some nodes. The way it is currently implemented both were storing values of different precision in the database. I have created a failing test for that. This is only visible if the mysql fields are at least double. I added a migration in the dummy app. float is anyway completely insufficient for any serious application as it may suffer on underflow as early as at tree depth 7.

Additionally I think that the geopolitical theme in the unit tests actually makes it difficult to write extensive tests.