From b383c67fa59a5be6e702ed2c1e4c828bdb79210f Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Sun, 8 May 2016 23:53:58 +0530 Subject: [PATCH] Treat the Array different from the Object to make sure session tracking works well with it. --- web/pgadmin/browser/static/js/datamodel.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/web/pgadmin/browser/static/js/datamodel.js b/web/pgadmin/browser/static/js/datamodel.js index 71e1cae6b..04a195fa0 100644 --- a/web/pgadmin/browser/static/js/datamodel.js +++ b/web/pgadmin/browser/static/js/datamodel.js @@ -114,6 +114,7 @@ function(_, pgAdmin, $, Backbone) { self.sessAttrs = {}; self.origSessAttrs = {}; self.objects = []; + self.arrays = []; self.attrName = options.attrName, self.top = (options.top || self.collection && self.collection.top || self.collection || self); self.handler = options.handler || @@ -129,7 +130,7 @@ function(_, pgAdmin, $, Backbone) { switch(s.type) { case 'array': - self.objects.push(s.id); + self.arrays.push(s.id); break; case 'collection': @@ -385,6 +386,19 @@ function(_, pgAdmin, $, Backbone) { res[k] = (obj && obj.toJSON()); } }); + if (session) { + _.each( + self.arrays, + function(a) { + /* + * For session changes, we only need the modified data to be + * transformed to JSON data. + */ + if (res[a] && res[a] instanceof Array) { + res[a] = JSON.stringify(res[a]); + } + }); + } return res; }, startNewSession: function() {