When changing data source, save query only if it was saved