Fix for SQLA >=0.9

This fixes issue #101, which is caused by a change in SQLA introduced in 0.9 The change causes all searches that use "sort by evolution chain" to fail, resulting in a 500 error.
The code for the fix was provided by magical.