DB Server: Fix spaces handling in queries