Fix a potential issue in the custom query wizard.