improve ruby dialect // spot bug on mysql query