Query building now works for mysql as well as sqlite