fix datatype issue when saving queries