Fixed issue if there was trailing space in front of a database query on select