Fix db query in versions app, add backticks

Same as in #2336 

cc @eMerzh