Bug fix

Fixed a bug in which uppercase query may cause internal server error.