public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][RM4895] Possible issue in reset function for nested objects
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin][RM4895] Possible issue in reset function for nested objects
@ 2019-11-05 06:58  Ganesh Jaybhay <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Ganesh Jaybhay @ 2019-11-05 06:58 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Hackers,

Please find the attached patch to fix the possible issue in reset function
for nested objects.

Regards,
Ganesh Jaybhay


Attachments:

  [application/octet-stream] RM4895.patch (2.4K, 3-RM4895.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/static/js/collection.js b/web/pgadmin/browser/static/js/collection.js
index 1b4d195..51919fd 100644
--- a/web/pgadmin/browser/static/js/collection.js
+++ b/web/pgadmin/browser/static/js/collection.js
@@ -188,7 +188,7 @@ define([
           'remove': function() {
             if (this.grid) {
               if (this.grid.collection) {
-                this.grid.collection.reset({silent: true});
+                this.grid.collection.reset([], {silent: true});
                 delete (this.grid.collection);
               }
               delete (this.grid);
diff --git a/web/pgadmin/browser/static/js/datamodel.js b/web/pgadmin/browser/static/js/datamodel.js
index ed66354..514c403 100644
--- a/web/pgadmin/browser/static/js/datamodel.js
+++ b/web/pgadmin/browser/static/js/datamodel.js
@@ -283,11 +283,17 @@ define([
     },
     // Create a reset function, which allow us to remove the nested object.
     reset: function(opts) {
-      var obj;
+      var obj,
+        reindex = !!(opts && opts.reindex);
 
       if (opts && opts.stop)
         this.stopSession();
 
+      // Let's not touch the child attributes, if reindex is false.
+      if (!reindex) {
+        return;
+      }
+
       for (var id in this.objects) {
         obj = this.get(id);
 
@@ -297,7 +303,7 @@ define([
           } else if (obj instanceof Backbone.Model) {
             obj.clear(opts);
           } else if (obj instanceof pgBrowser.DataCollection) {
-            obj.reset(opts);
+            obj.reset([], opts);
           } else if (obj instanceof Backbone.Collection) {
             obj.each(function(m) {
               if (m instanceof Backbone.DataModel) {
@@ -305,14 +311,11 @@ define([
                 obj.clear(opts);
               }
             });
-            if (!(opts instanceof Array)) {
-              opts = [opts];
-            }
-            Backbone.Collection.prototype.reset.apply(obj, opts);
+            Backbone.Collection.prototype.reset.call(obj, [], opts);
           }
         }
       }
-      this.clear(opts);
+      Backbone.Collection.prototype.reset.apply(this, arguments);
     },
     sessChanged: function() {
       var self = this;
@@ -996,7 +999,7 @@ define([
     },
     // Override the reset function, so that - we can reset the model
     // properly.
-    reset: function(opts) {
+    reset: function(_set, opts) {
       if (opts && opts.stop)
         this.stopSession();
       this.each(function(m) {


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin][RM4895] Possible issue in reset function for nested objects
@ 2019-11-05 09:18  Akshay Joshi <[email protected]>
  parent: Ganesh Jaybhay <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2019-11-05 09:18 UTC (permalink / raw)
  To: Ganesh Jaybhay <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Tue, Nov 5, 2019 at 12:28 PM Ganesh Jaybhay <
[email protected]> wrote:

> Hi Hackers,
>
> Please find the attached patch to fix the possible issue in reset function
> for nested objects.
>
> Regards,
> Ganesh Jaybhay
>


-- 
*Thanks & Regards*
*Akshay Joshi*

*Sr. Software Architect*
*EnterpriseDB Software India Private Limited*
*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-11-05 09:18 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 06:58 [pgAdmin][RM4895] Possible issue in reset function for nested objects Ganesh Jaybhay <[email protected]>
2019-11-05 09:18 ` Akshay Joshi <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox