Reset query properties after saving the query
Update query only if query string is available

This prevents inadvertently overwriting an existing query's properties if a
query string value is missing. See the comment for a complete justification.
Merge pull request #2266 from opf/hotfix/17554_removing_grouping_not_saved_on_existing_queries

17554 removing grouping not saved on existing queries
Merge branch 'release/4.0' into dev