diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index 73fea1db4..43510cdd1 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -111,7 +111,7 @@ body {
-
+
{{ _('Auto-Commit') }}
diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py
index 18bf51954..12d9ae8d8 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -321,13 +321,26 @@ def start_query_tool(trans_id):
)
-@blueprint.route('/query_tool/preferences', methods=["GET", "PUT"])
+@blueprint.route('/query_tool/preferences/', methods=["GET", "PUT"])
@login_required
-def get_preferences():
+def preferences(trans_id):
"""
This method is used to get/put explain options from/to preferences
+
+ Args:
+ trans_id: unique transaction id
"""
if request.method == 'GET':
+
+ # Check the transaction and connection status
+ status, error_msg, conn, trans_obj, session_obj = check_transaction_status(trans_id)
+ if status and conn is not None \
+ and trans_obj is not None and session_obj is not None:
+
+ # Call the set_auto_commit method of transaction object
+ trans_obj.set_auto_commit(blueprint.auto_commit.get())
+ trans_obj.set_auto_rollback(blueprint.auto_rollback.get())
+
return make_json_response(
data={
'explain_verbose': blueprint.explain_verbose.get(),
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 4f18abf3b..2910586dd 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -305,8 +305,10 @@ define(
* values from preferences
*/
get_preferences: function() {
+ var self = this;
+
$.ajax({
- url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
+ url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences/" + self.transId ,
method: 'GET',
async: false,
success: function(res) {
@@ -863,7 +865,7 @@ define(
el: self.container,
handler: self
});
- self.transId = self.container.data('transId');
+ self.transId = self.gridView.transId = self.container.data('transId');
self.gridView.editor_title = editor_title;
self.gridView.current_file = undefined;
@@ -2409,25 +2411,26 @@ define(
var data = {
'explain_verbose': self.explain_verbose
};
+
$.ajax({
- url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
- method: 'PUT',
- contentType: "application/json",
- data: JSON.stringify(data),
- success: function(res) {
- if(res.success == undefined || !res.success) {
+ url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
+ method: 'PUT',
+ contentType: "application/json",
+ data: JSON.stringify(data),
+ success: function(res) {
+ if(res.success == undefined || !res.success) {
+ alertify.alert('Explain options error',
+ '{{ _('Error occurred while setting verbose option in explain') }}'
+ );
+ }
+ },
+ error: function(e) {
alertify.alert('Explain options error',
- '{{ _('Error occurred while setting verbose option in explain') }}'
+ '{{ _('Error occurred while setting verbose option in explain') }}'
);
+ return;
}
- },
- error: function(e) {
- alertify.alert('Explain options error',
- '{{ _('Error occurred while setting verbose option in explain') }}'
- );
- return;
- }
- });
+ });
},
// This function will toggle "costs" option in explain
@@ -2445,24 +2448,25 @@ define(
var data = {
'explain_costs': self.explain_costs
};
+
$.ajax({
- url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
- method: 'PUT',
- contentType: "application/json",
- data: JSON.stringify(data),
- success: function(res) {
- if(res.success == undefined || !res.success) {
+ url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
+ method: 'PUT',
+ contentType: "application/json",
+ data: JSON.stringify(data),
+ success: function(res) {
+ if(res.success == undefined || !res.success) {
+ alertify.alert('Explain options error',
+ '{{ _('Error occurred while setting costs option in explain') }}'
+ );
+ }
+ },
+ error: function(e) {
alertify.alert('Explain options error',
- '{{ _('Error occurred while setting costs option in explain') }}'
+ '{{ _('Error occurred while setting costs option in explain') }}'
);
}
- },
- error: function(e) {
- alertify.alert('Explain options error',
- '{{ _('Error occurred while setting costs option in explain') }}'
- );
- }
- });
+ });
},
// This function will toggle "buffers" option in explain
@@ -2480,25 +2484,25 @@ define(
var data = {
'explain_buffers': self.explain_buffers
};
+
$.ajax({
- url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
- method: 'PUT',
- contentType: "application/json",
- data: JSON.stringify(data),
- success: function(res) {
- if(res.success == undefined || !res.success) {
+ url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
+ method: 'PUT',
+ contentType: "application/json",
+ data: JSON.stringify(data),
+ success: function(res) {
+ if(res.success == undefined || !res.success) {
+ alertify.alert('Explain options error',
+ '{{ _('Error occurred while setting buffers option in explain') }}'
+ );
+ }
+ },
+ error: function(e) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting buffers option in explain') }}'
);
}
- },
- error: function(e) {
- alertify.alert('Explain options error',
- '{{ _('Error occurred while setting buffers option in explain') }}'
- );
- }
- });
-
+ });
},
// This function will toggle "timing" option in explain
@@ -2515,25 +2519,25 @@ define(
var data = {
'explain_timing': self.explain_timing
};
+
$.ajax({
- url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
- method: 'PUT',
- contentType: "application/json",
- data: JSON.stringify(data),
- success: function(res) {
- if(res.success == undefined || !res.success) {
+ url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
+ method: 'PUT',
+ contentType: "application/json",
+ data: JSON.stringify(data),
+ success: function(res) {
+ if(res.success == undefined || !res.success) {
+ alertify.alert('Explain options error',
+ '{{ _('Error occurred while setting timing option in explain') }}'
+ );
+ }
+ },
+ error: function(e) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting timing option in explain') }}'
);
}
- },
- error: function(e) {
- alertify.alert('Explain options error',
- '{{ _('Error occurred while setting timing option in explain') }}'
- );
- }
- });
-
+ });
}
}
);