'Modify a query.
:param query_id: ID of query to update
:<json number data_source_id: The ID of the data source this query will run on
:<json string query: Query text
:<json string name:
:<json string description:
:<json string schedule: Schedule interval, in seconds, for repeated execution of this query
:<json object options: Query options
Responds with the updated :ref:`query <query-response-label>` object.'

@require_permission('edit_query')
def post(self, query_id):

    query = get_object_or_404(models.Query.get_by_id_and_org, query_id, self.current_org)
    query_def = request.get_json(force=True)
    require_object_modify_permission(query, self.current_user)
    for field in ['id', 'created_at', 'api_key', 'visualizations', 'latest_query_data', 'user', 'last_modified_by', 'org']:
        query_def.pop(field, None)
    if ('query' in query_def):
        query_def['query_text'] = query_def.pop('query')
    query_def['last_modified_by'] = self.current_user
    query_def['changed_by'] = self.current_user
    if (('version' in query_def) and (query_def['version'] != query.version)):
        abort(409)
    try:
        self.update_model(query, query_def)
        models.db.session.commit()
    except StaleDataError:
        abort(409)
    return query.to_dict(with_visualizations=True)
