[pgAdmin][RM5043] Column names not in creation order during - refresh via context menu required to resort them properly

2020-04-22 Thread Satish V
Hi Hackers,

In the attached patch, newly created columns in a table are sorted
according to their creation order rather than the alphanumerical order.
Previously this was not happening without context refresh.



Please review.

Thanks
Sathish V
diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js
index 9a2980a..2c50ab0 100644
--- a/web/pgadmin/browser/static/js/browser.js
+++ b/web/pgadmin/browser/static/js/browser.js
@@ -1001,12 +1001,12 @@ define('pgadmin.browser', [
   while (e >= s) {
 i = items.eq(s);
 var d = ctx.t.itemData(i);
-if (
-  pgAdmin.natural_sort(
-d._label, _data._label
-  ) == 1
-)
-  return true;
+if(d._type==='column'){
+  if (pgAdmin.numeric_comparator(d._id, _data._id) == 1) return true;
+}
+else{
+  if (pgAdmin.natural_sort(d._label, _data._label) == 1) return true;
+}
 s++;
   }
   if (e != items.length - 1) {
@@ -1026,24 +1026,48 @@ define('pgadmin.browser', [
   while (e - s > 22) {
 i = items.eq(s);
 d = ctx.t.itemData(i);
-if (
-  pgAdmin.natural_sort(
-d._label, _data._label
-  ) != -1
-)
-  return true;
+if(d._type==='column'){
+  if (
+pgAdmin.numeric_comparator(
+  d._id, _data._id
+) != -1
+  )
+return true;
+}
+else{
+  if (
+pgAdmin.natural_sort(
+  d._label, _data._label
+) != -1
+  )
+return true;
+}
 i = items.eq(e);
 d = ctx.t.itemData(i);
-if (
-  pgAdmin.natural_sort(
-d._label, _data._label
-  ) != 1
-)
-  return true;
+if(d._type==='column'){
+  if (
+pgAdmin.numeric_comparator(
+  d._id, _data._id
+) == -1)
+return false;
+}
+else{
+  if (
+pgAdmin.natural_sort(
+  d._label, _data._label
+) != 1)
+return true;
+}
 m = s + Math.round((e - s) / 2);
 i = items.eq(m);
 d = ctx.t.itemData(i);
-res = pgAdmin.natural_sort(d._label, _data._label);
+if(d._type==='column'){
+  res = pgAdmin.numeric_comparator(d._id, _data._id);
+}
+else{
+  res = pgAdmin.natural_sort(d._label, _data._label);
+}
+
 if (res == 0)
   return true;
 
diff --git a/web/pgadmin/static/js/pgadmin.js b/web/pgadmin/static/js/pgadmin.js
index 68a86af..8f36410 100644
--- a/web/pgadmin/static/js/pgadmin.js
+++ b/web/pgadmin/static/js/pgadmin.js
@@ -115,6 +115,15 @@ define([], function() {
 return 0;
   };
 
+  pgAdmin.numeric_comparator = function(a,b) {
+a= parseInt(a);
+b= parseInt(b);
+if (a < b)
+  return -1 ;
+else
+  return 1 ;
+  };
+
   /**
* Decimal adjustment of a number.
*


Re: [pgAdmin][RM5043] Column names not in creation order during - refresh via context menu required to resort them properly

2020-04-27 Thread Satish V
Hi,

Here is an updated patch which makes the columns(44 and more ) showing up
in the creation order rather than alphabetical sorting. Changes happen
inside the browser tree.

Thanks & Regards
Sathish V

On Thu, Apr 23, 2020 at 8:04 AM Akshay Joshi 
wrote:

> Thanks, patch applied.
>
> On Thu, Apr 23, 2020 at 12:02 PM navnath gadakh <
> navnath.gad...@enterprisedb.com> wrote:
>
>> Hello,
>>
>>  Patch looks good to me. Newly created columns sorted according to their
>> creation order without context refresh.
>>
>> Thanks!
>>
>> On Thu, Apr 23, 2020 at 10:13 AM navnath gadakh <
>> navnath.gad...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>>  I'm reviewing this patch.
>>>
>>> On Wed, Apr 22, 2020 at 6:54 PM Satish V 
>>> wrote:
>>>
>>>>
>>>> Hi Hackers,
>>>>
>>>> In the attached patch, newly created columns in a table are sorted
>>>> according to their creation order rather than the alphanumerical order.
>>>> Previously this was not happening without context refresh.
>>>>
>>>>
>>>>
>>>> Please review.
>>>>
>>>> Thanks
>>>> Sathish V
>>>>
>>>
>>>
>>> --
>>> Regards,
>>> Navnath Gadakh
>>>
>>
>>
>> --
>> Regards,
>> Navnath Gadakh
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
>
> *Sr. Software Architect*
> *EnterpriseDB Software India Private Limited*
> *Mobile: +91 976-788-8246*
>
diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js
index 4ed30a2..20b2eb2 100644
--- a/web/pgadmin/browser/static/js/browser.js
+++ b/web/pgadmin/browser/static/js/browser.js
@@ -1037,8 +1037,8 @@ define('pgadmin.browser', [
 i = items.eq(e);
 d = ctx.t.itemData(i);
 if (d._type === 'column') {
-  if (pgAdmin.numeric_comparator(d._id, _data._id) != -1)
-return true;
+  if (pgAdmin.numeric_comparator(d._id, _data._id) == -1)
+return false;
 } else {
   if (pgAdmin.natural_sort(d._label, _data._label) != 1)
 return true;


RM3694-If database is already connected and click on database then connect database should not displayed in Menu

2020-04-29 Thread Satish V
Hi Hackers,

In the patch attached, we are gracefully informing the end user, using an
alert message, that the database is already connected when they click
"Connect Database..." after right clicking on a disconnected database.

As this problem deals with racing conditions, it is highly complex to show
the "Disconnect database" option in the menu upon right click. So we are
alerting the end user with the information of "Database already connected".

Thanks,
Sathish V
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 9216f21..a931371 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -456,6 +456,7 @@ class DatabaseView(PGChildNodeView):
 from pgadmin.utils.driver import get_driver
 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
 conn = manager.connection(did=did, auto_reconnect=True)
+info_already_connected = conn.connected()
 status, errmsg = conn.connect()
 
 if not status:
@@ -469,13 +470,14 @@ class DatabaseView(PGChildNodeView):
 else:
 current_app.logger.info('Connection Established for Database Id: \
 %s' % (did))
-
 return make_json_response(
 success=1,
-info=_("Database connected."),
+info=_("Database already connected") if info_already_connected
+else _("Database connected"),
 data={
 'icon': 'pg-icon-database',
 'connected': True,
+'info_already_connected': info_already_connected,
 'info_prefix': '{0}/{1}'.
 format(Server.query.filter_by(id=sid)[0].name, conn.db)
 }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
index f458d69..24e7205 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
@@ -534,7 +534,13 @@ define('pgadmin.node.database', [
 res.info = `${_.escape(res.data.info_prefix)} - ${res.info}`;
   }
 
-  Alertify.success(res.info);
+  if(res.data.info_already_connected){
+Alertify.error(res.info);
+  } else {
+Alertify.success(res.info);
+  }
+
+
   obj.trigger('connected', obj, item, data);
   pgBrowser.Events.trigger(
 'pgadmin:database:connected', item, data


Re: RM3694-If database is already connected and click on database then connect database should not displayed in Menu

2020-04-29 Thread Satish V
Hi Kushboo,

Thanks for the update. I will check the same and make appropriate changes.

Thanks,
Sathish

On Thu, Apr 30, 2020 at 9:20 AM Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi Satish,
>
> As per the RM, the fix is supposed to be at the front-end but it seems
> difficult at the moment as on the selection of the database, we connect it
> and at the same time the context menu is being called.
> As you have tried to fix at the backend, some of the review comments are
> below.
>
> 1.  If the database is already connected, no need to call conn.connect
> again.
>
>
> info_already_connected = conn.connected()
>
> status, errmsg = conn.connect()
>
> 2. If you want to raise an error at the client side, use the appropriate 
> function or status (check file ajax.py) at the server side and send the 
> appropriate response.
>
> Below code needs to be changed.
>
> if(res.data.info_already_connected){
>
>   Alertify.error(res.info);
>
> } else {
>
>   Alertify.success(res.info);
>
> }
>
> Thanks,
>
> Khushboo
>
>
>
> On Wed, Apr 29, 2020 at 8:20 PM Satish V 
> wrote:
>
>> Hi Hackers,
>>
>> In the patch attached, we are gracefully informing the end user, using an
>> alert message, that the database is already connected when they click
>> "Connect Database..." after right clicking on a disconnected database.
>>
>> As this problem deals with racing conditions, it is highly complex to
>> show the "Disconnect database" option in the menu upon right click. So we
>> are alerting the end user with the information of "Database already
>> connected".
>>
>> Thanks,
>> Sathish V
>>
>


Re: RM3694-If database is already connected and click on database then connect database should not displayed in Menu

2020-04-30 Thread Satish V
Hi,

I made the changes to the code such that conn.connect() will happen only
when there is no prior connection exist. In short, connection via context
menu will not trigger this conn.connect().
In the client side code, instead of error alert, info alert is used to
inform the user.

Kindly review the patch and suggest the changes if required.

Thanks,
Sathish V

On Thu, Apr 30, 2020 at 2:43 AM Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

>
>
> On Thu, Apr 30, 2020 at 12:04 PM Aditya Toshniwal <
> aditya.toshni...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> On Thu, Apr 30, 2020 at 11:55 AM Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Thu, Apr 30, 2020 at 10:55 AM Aditya Toshniwal <
>>> aditya.toshni...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> On Thu, Apr 30, 2020 at 10:48 AM Khushboo Vashi <
>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Thu, Apr 30, 2020 at 10:14 AM Aditya Toshniwal <
>>>>> aditya.toshni...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>>
>>>>>> On Thu, Apr 30, 2020 at 9:41 AM Satish V 
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Kushboo,
>>>>>>>
>>>>>>> Thanks for the update. I will check the same and make
>>>>>>> appropriate changes.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Sathish
>>>>>>>
>>>>>>> On Thu, Apr 30, 2020 at 9:20 AM Khushboo Vashi <
>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>> Hi Satish,
>>>>>>>>
>>>>>>>> As per the RM, the fix is supposed to be at the front-end but it
>>>>>>>> seems difficult at the moment as on the selection of the database, we
>>>>>>>> connect it and at the same time the context menu is being called.
>>>>>>>> As you have tried to fix at the backend, some of the review
>>>>>>>> comments are below.
>>>>>>>>
>>>>>>>> 1.  If the database is already connected, no need to call
>>>>>>>> conn.connect again.
>>>>>>>>
>>>>>>>>
>>>>>>>> info_already_connected = conn.connected()
>>>>>>>>
>>>>>>>> status, errmsg = conn.connect()
>>>>>>>>
>>>>>>>> I've noticed conn.connected() is misleading sometimes. Let's say if
>>>>>> the PG server is stopped and no query is fired from pgadmin after that,
>>>>>> then conn.connected() will still give True. It is updated only when
>>>>>> a query is fired to the PG server. I would suggest let it connect again 
>>>>>> as
>>>>>> there is no harm and this function is very important. We don't want to 
>>>>>> mess
>>>>>> it up for the sake of a message.
>>>>>>
>>>>> It's true that conn.connected() is misleading but we already get the
>>>>> connection before checking conn.connected() with conn =
>>>>> manager.connection(did=did, auto_reconnect=True).
>>>>> So, if the database server is stopped, it will throw the error.
>>>>>
>>>> I just checked the manager.connection function, and it is not
>>>> connecting or checking. It will just give the connection object stored in
>>>> the memory.
>>>>
>>> :).
>>>
>>>
>>> databases/__init__.py : def connect()
>>>
>>>
>>> manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
>>>
>>> conn = manager.connection(did=did, auto_reconnect=True)
>>>
>>>
>>>
>>> Above 2 lines will handle which I just just mentioned above.
>>>
>> I didn't find any code which will call the connect, apart
>> from auto_reconnect being used when we execute some query. Nevertheless, I
>> still believe we should not remove the connect call for the sake of a
>> message, for which I think the user won't even bother.
>>
>>>
>>>
>> To understand the code properly, comment ou

Re: RM3694-If database is already connected and click on database then connect database should not displayed in Menu

2020-04-30 Thread Satish V
Hi Khushboo,

In the attached patch,
Fixed pep8 and made use of 'gettext' inside "database.js" file...
Regarding *res.info <http://res.info>='Database already connected', **we
are appending the database name and server name in front of 'res.info
<http://res.info>' string in the very next line. So using this 'Database
already connected' text directly inside alertify will stop it from showing
the info pertaining to the server and database. -* no changes are done
about res.info.

Thanks
Sathish

On Thu, Apr 30, 2020 at 7:40 AM Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi Satish,
>
> Some minor comments:
>
> - Fix PEP8 issues.
> - Use gettext in database.js file for the info message.
> - No need to assign text value in res object (res.info = 'Database
> already connected.'), use this text directly in Alertify.info.
>
> Thanks,
> Khushboo
>
>
>
>
>
> On Thu, Apr 30, 2020 at 1:59 PM Satish V 
> wrote:
>
>> Hi,
>>
>> I made the changes to the code such that conn.connect() will happen only
>> when there is no prior connection exist. In short, connection via context
>> menu will not trigger this conn.connect().
>> In the client side code, instead of error alert, info alert is used to
>> inform the user.
>>
>> Kindly review the patch and suggest the changes if required.
>>
>> Thanks,
>> Sathish V
>>
>> On Thu, Apr 30, 2020 at 2:43 AM Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Thu, Apr 30, 2020 at 12:04 PM Aditya Toshniwal <
>>> aditya.toshni...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> On Thu, Apr 30, 2020 at 11:55 AM Khushboo Vashi <
>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Thu, Apr 30, 2020 at 10:55 AM Aditya Toshniwal <
>>>>> aditya.toshni...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> On Thu, Apr 30, 2020 at 10:48 AM Khushboo Vashi <
>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Apr 30, 2020 at 10:14 AM Aditya Toshniwal <
>>>>>>> aditya.toshni...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Apr 30, 2020 at 9:41 AM Satish V 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi Kushboo,
>>>>>>>>>
>>>>>>>>> Thanks for the update. I will check the same and make
>>>>>>>>> appropriate changes.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Sathish
>>>>>>>>>
>>>>>>>>> On Thu, Apr 30, 2020 at 9:20 AM Khushboo Vashi <
>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Satish,
>>>>>>>>>>
>>>>>>>>>> As per the RM, the fix is supposed to be at the front-end but it
>>>>>>>>>> seems difficult at the moment as on the selection of the database, we
>>>>>>>>>> connect it and at the same time the context menu is being called.
>>>>>>>>>> As you have tried to fix at the backend, some of the review
>>>>>>>>>> comments are below.
>>>>>>>>>>
>>>>>>>>>> 1.  If the database is already connected, no need to call
>>>>>>>>>> conn.connect again.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> info_already_connected = conn.connected()
>>>>>>>>>>
>>>>>>>>>> status, errmsg = conn.connect()
>>>>>>>>>>
>>>>>>>>>> I've noticed conn.connected() is misleading sometimes. Let's say
>>>>>>>> if the PG server is stopped and no query is fired from pgadmin after 
>>>>>>>> that,
>>>>>>>> then conn.connected() will still give True. It is updated onl

Re: RM3694-If database is already connected and click on database then connect database should not displayed in Menu

2020-05-04 Thread Satish V
Hi Khushboo,

As we discussed, the database disconnection error message is ignored as it
is getting displayed as expected. Variable name , info_already_connected,
is changed to already_connected. Run all the test cases except the feature
test. Number of test case failures before and after the patch remain the
same.

Thanks,
Sathish V

On Mon, May 4, 2020 at 12:04 AM Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi Satish,
>
> On Thu, Apr 30, 2020 at 8:29 PM Satish V 
> wrote:
>
>> Hi Khushboo,
>>
>> In the attached patch,
>> Fixed pep8 and made use of 'gettext' inside "database.js" file...
>> Regarding *res.info <http://res.info>='Database already connected', **we
>> are appending the database name and server name in front of 'res.info
>> <http://res.info>' string in the very next line. So using this 'Database
>> already connected' text directly inside alertify will stop it from showing
>> the info pertaining to the server and database. -* no changes are done
>> about res.info.
>>
>> The database disconnection error comes without a database name. To
> reproduce this issue, perform the steps in this RM and then try to
> disconnect the database.
> Also, please give the proper variable name as we discussed.
>
> Thanks,
> Khushboo
>
> Thanks
>
>> Sathish
>>
>> On Thu, Apr 30, 2020 at 7:40 AM Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi Satish,
>>>
>>> Some minor comments:
>>>
>>> - Fix PEP8 issues.
>>> - Use gettext in database.js file for the info message.
>>> - No need to assign text value in res object (res.info = 'Database
>>> already connected.'), use this text directly in Alertify.info.
>>>
>>> Thanks,
>>> Khushboo
>>>
>>>
>>>
>>>
>>>
>>> On Thu, Apr 30, 2020 at 1:59 PM Satish V 
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I made the changes to the code such that conn.connect() will happen
>>>> only when there is no prior connection exist. In short, connection via
>>>> context menu will not trigger this conn.connect().
>>>> In the client side code, instead of error alert, info alert is used to
>>>> inform the user.
>>>>
>>>> Kindly review the patch and suggest the changes if required.
>>>>
>>>> Thanks,
>>>> Sathish V
>>>>
>>>> On Thu, Apr 30, 2020 at 2:43 AM Khushboo Vashi <
>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Thu, Apr 30, 2020 at 12:04 PM Aditya Toshniwal <
>>>>> aditya.toshni...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> On Thu, Apr 30, 2020 at 11:55 AM Khushboo Vashi <
>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Apr 30, 2020 at 10:55 AM Aditya Toshniwal <
>>>>>>> aditya.toshni...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> On Thu, Apr 30, 2020 at 10:48 AM Khushboo Vashi <
>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, Apr 30, 2020 at 10:14 AM Aditya Toshniwal <
>>>>>>>>> aditya.toshni...@enterprisedb.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thu, Apr 30, 2020 at 9:41 AM Satish V <
>>>>>>>>>> satis...@enterprisedb.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Kushboo,
>>>>>>>>>>>
>>>>>>>>>>> Thanks for the update. I will check the same and make
>>>>>>>>>>> appropriate changes.
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>> Sathish
>>>>>>>>>>>
>>>>>>>>>>> On Thu, Apr 30, 2020 at 9:20 AM K

RM-5434 (New table added is not alphabetically added to the tree)

2020-05-07 Thread Satish V
Hi Hackers,

In the patch attached,
1.Creation or updation of Tables and all other entities will be sorted
according to their names.
2.Exception- Columns will be sorted according to their creation
order(position ID).

This Patch also resolves RM 5450. Kindly review and share the suggestions
if required.


Thanks,
Sathish V
diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js
index 098e1da..f0518a4 100644
--- a/web/pgadmin/browser/static/js/browser.js
+++ b/web/pgadmin/browser/static/js/browser.js
@@ -1011,15 +1011,16 @@ define('pgadmin.browser', [
 }
 s++;
   }
+  //when the current element is greater than the end element
   if (e != items.length - 1) {
-i = items.eq(e);
+i = items.eq(e+1);
 return true;
   }
   i = null;
   return false;
 },
 binarySearch = function() {
-  var d, m, res;
+  var d, m;
   // Binary search only outperforms Linear search for n > 44.
   // Reference:
   // https://en.wikipedia.org/wiki/Binary_search_algorithm#cite_note-30
@@ -1037,26 +1038,34 @@ define('pgadmin.browser', [
 }
 i = items.eq(e);
 d = ctx.t.itemData(i);
+let result;
 if (d._type === 'column') {
-  if (pgAdmin.numeric_comparator(d._id, _data._id) == -1)
-return false;
+  result = pgAdmin.numeric_comparator(d._id, _data._id);
 } else {
-  if (pgAdmin.natural_sort(d._label, _data._label) != 1)
+  result = pgAdmin.natural_sort(d._label, _data._label);
+}
+if (result !=1) {
+  if (e != items.length - 1) {
+i = items.eq(e+1);
 return true;
+  }
+  i = null;
+  return false;
 }
 m = s + Math.round((e - s) / 2);
 i = items.eq(m);
 d = ctx.t.itemData(i);
 if(d._type === 'column'){
-  res = pgAdmin.numeric_comparator(d._id, _data._id);
+  result = pgAdmin.numeric_comparator(d._id, _data._id);
 } else {
-  res = pgAdmin.natural_sort(d._label, _data._label);
+  result = pgAdmin.natural_sort(d._label, _data._label);
 }
-
-if (res == 0)
+//result will never become 0 because of remove operation
+//which happens with updateTreeNode
+if (result == 0)
   return true;
 
-if (res == -1) {
+if (result == -1) {
   s = m + 1;
   e--;
 } else {
@@ -1509,16 +1518,17 @@ define('pgadmin.browser', [
   while (e >= s) {
 i = items.eq(s);
 var d = ctx.t.itemData(i);
-if (
-  pgAdmin.natural_sort(
-d._label, _new._label
-  ) == 1
-)
-  return true;
+if (d._type === 'column') {
+  if (pgAdmin.numeric_comparator(d._id, _new._id) == 1)
+return true;
+} else {
+  if (pgAdmin.natural_sort(d._label, _new._label) == 1)
+return true;
+}
 s++;
   }
   if (e != items.length - 1) {
-i = items.eq(e);
+i = items.eq(e+1);
 return true;
   }
   i = null;
@@ -1528,28 +1538,43 @@ define('pgadmin.browser', [
   while (e - s > 22) {
 i = items.eq(s);
 var d = ctx.t.itemData(i);
-if (
-  pgAdmin.natural_sort(
-d._label, _new._label
-  ) != -1
-)
-  return true;
+if (d._type === 'column') {
+  if (pgAdmin.numeric_comparator(d._id, _new._id) != -1)
+return true;
+} else {
+  if (pgAdmin.natural_sort(d._label, _new._label) != -1)
+return true;
+}
 i = items.eq(e);
 d = ctx.t.itemData(i);
-

Re- [RM-3669]If user drop any object and click on create script, count rows and Truncate table, proper error should displayed that object is in present

2020-06-01 Thread Satish V
Hi Hackers,

Attached is the patch which alerts the users when they try to consume the
options in the context menu of the deleted node.
-fixed the opening of an empty query tool window for non existing
nodes.(create/delete/update..)
- handles the error like "list index out of range" with a reasonable error
dialog or alert.

Kindly review the patch and let me know of the changes required.


Thanks,
Sathish V


RM3669s1.patch
Description: Binary data


Re: Re- [RM-3669]If user drop any object and click on create script, count rows and Truncate table, proper error should displayed that object is in present

2020-06-02 Thread Satish V
Hi Kushboo,

All the menus for all the deleted nodes were handled except Maintenance,
backup /restore, import/export.

Scripts,Refers View,View/Edit data and Create- child nodes for any parent
node which is deleted are handled.
Refresh, Delete/drop,drop cascade and properties were already handled for
all the nodes. So i didn't make changes to them as they are displaying
proper error messages already and I checked it for all the nodes.


Thanks
Sathish V

On Tue, Jun 2, 2020 at 12:22 PM Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi Satish,
>
> On Mon, Jun 1, 2020 at 2:16 PM Satish V  wrote:
>
>> Hi Hackers,
>>
>> Attached is the patch which alerts the users when they try to consume the
>> options in the context menu of the deleted node.
>>
> Can you please specify the context menu options which you handled, so it
> will be easy for me to review.
>
> Thanks,
> Khushboo
>
>> -fixed the opening of an empty query tool window for non existing
>> nodes.(create/delete/update..)
>> - handles the error like "list index out of range" with a reasonable
>> error dialog or alert.
>>
>> Kindly review the patch and let me know of the changes required.
>>
>>
>> Thanks,
>> Sathish V
>>
>


Re: Re- [RM-3669]If user drop any object and click on create script, count rows and Truncate table, proper error should displayed that object is in present

2020-06-02 Thread Satish V
Hi Khushboo,

The Reason for checking status==410 is to show error dialog to the user
which will not go unnoticed at any situation. For closing the empty query
tool we need this error dialog pop which shows the error message and closes
the empty query tool for deleted nodes upon clicking ok.

Changes inside the "alertify.pgadmin.defaults.js file" is made to avoid
repeating the same patch which calls pgBrowser.report_error(which is used
to show the error dialog message), in multiple places .

Changes inside database.js file are made to make sure that the error
message has the proper title, which was missing previously for the "connect
database" context menu.

-fixed the issues related to spacing between the operators.

Please find the updated patch in the attached file.

Thanks,
Sathish V

On Tue, Jun 2, 2020 at 2:40 PM Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi Satish,
>
> - On failure, you have added a new condition if (e.status == 410) at some
> places, this is not necessary as we have generalised code for that.
> - Please maintain the consistency in messages, you can check the GONE
> message template, we do have them at some places. (Example: on Database
> expansion )
> - Please follow basic JS coding standards. Ex: A space is required
> after/before any operator. I have seen 1 or 2 places where a space is
> missing in your patch.
>
> Thanks,
> Khushboo
>
> On Tue, Jun 2, 2020 at 12:45 PM Satish V 
> wrote:
>
>> Hi Kushboo,
>>
>> All the menus for all the deleted nodes were handled except Maintenance,
>> backup /restore, import/export.
>>
>> Scripts,Refers View,View/Edit data and Create- child nodes for any parent
>> node which is deleted are handled.
>> Refresh, Delete/drop,drop cascade and properties were already handled for
>> all the nodes. So i didn't make changes to them as they are displaying
>> proper error messages already and I checked it for all the nodes.
>>
>>
>> Thanks
>> Sathish V
>>
>> On Tue, Jun 2, 2020 at 12:22 PM Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi Satish,
>>>
>>> On Mon, Jun 1, 2020 at 2:16 PM Satish V 
>>> wrote:
>>>
>>>> Hi Hackers,
>>>>
>>>> Attached is the patch which alerts the users when they try to consume
>>>> the options in the context menu of the deleted node.
>>>>
>>> Can you please specify the context menu options which you handled, so it
>>> will be easy for me to review.
>>>
>>> Thanks,
>>> Khushboo
>>>
>>>> -fixed the opening of an empty query tool window for non existing
>>>> nodes.(create/delete/update..)
>>>> - handles the error like "list index out of range" with a reasonable
>>>> error dialog or alert.
>>>>
>>>> Kindly review the patch and let me know of the changes required.
>>>>
>>>>
>>>> Thanks,
>>>> Sathish V
>>>>
>>>


Rm3669s2.patch
Description: Binary data


Re: Re- [RM-3669]If user drop any object and click on create script, count rows and Truncate table, proper error should displayed that object is in present

2020-06-03 Thread Satish V
Hi,
The erroneous import statement is solved in the patch attached...
I Ran the test cases again and found no errors.
Below patch contains the change in the import statements alone.

Thanks,
Sathish V


On Wed, Jun 3, 2020 at 11:27 AM Akshay Joshi 
wrote:

> Thanks, patch applied.
>
> On Tue, Jun 2, 2020 at 6:36 PM Satish V  wrote:
>
>> Hi Khushboo,
>>
>> The Reason for checking status==410 is to show error dialog to the user
>> which will not go unnoticed at any situation. For closing the empty query
>> tool we need this error dialog pop which shows the error message and closes
>> the empty query tool for deleted nodes upon clicking ok.
>>
>> Changes inside the "alertify.pgadmin.defaults.js file" is made to avoid
>> repeating the same patch which calls pgBrowser.report_error(which is used
>> to show the error dialog message), in multiple places .
>>
>> Changes inside database.js file are made to make sure that the error
>> message has the proper title, which was missing previously for the "connect
>> database" context menu.
>>
>> -fixed the issues related to spacing between the operators.
>>
>> Please find the updated patch in the attached file.
>>
>> Thanks,
>> Sathish V
>>
>> On Tue, Jun 2, 2020 at 2:40 PM Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi Satish,
>>>
>>> - On failure, you have added a new condition if (e.status == 410) at
>>> some places, this is not necessary as we have generalised code for that.
>>> - Please maintain the consistency in messages, you can check the GONE
>>> message template, we do have them at some places. (Example: on Database
>>> expansion )
>>> - Please follow basic JS coding standards. Ex: A space is required
>>> after/before any operator. I have seen 1 or 2 places where a space is
>>> missing in your patch.
>>>
>>> Thanks,
>>> Khushboo
>>>
>>> On Tue, Jun 2, 2020 at 12:45 PM Satish V 
>>> wrote:
>>>
>>>> Hi Kushboo,
>>>>
>>>> All the menus for all the deleted nodes were handled except
>>>> Maintenance, backup /restore, import/export.
>>>>
>>>> Scripts,Refers View,View/Edit data and Create- child nodes for any
>>>> parent node which is deleted are handled.
>>>> Refresh, Delete/drop,drop cascade and properties were already handled
>>>> for all the nodes. So i didn't make changes to them as they are displaying
>>>> proper error messages already and I checked it for all the nodes.
>>>>
>>>>
>>>> Thanks
>>>> Sathish V
>>>>
>>>> On Tue, Jun 2, 2020 at 12:22 PM Khushboo Vashi <
>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>
>>>>> Hi Satish,
>>>>>
>>>>> On Mon, Jun 1, 2020 at 2:16 PM Satish V 
>>>>> wrote:
>>>>>
>>>>>> Hi Hackers,
>>>>>>
>>>>>> Attached is the patch which alerts the users when they try to consume
>>>>>> the options in the context menu of the deleted node.
>>>>>>
>>>>> Can you please specify the context menu options which you handled, so
>>>>> it will be easy for me to review.
>>>>>
>>>>> Thanks,
>>>>> Khushboo
>>>>>
>>>>>> -fixed the opening of an empty query tool window for non existing
>>>>>> nodes.(create/delete/update..)
>>>>>> - handles the error like "list index out of range" with a reasonable
>>>>>> error dialog or alert.
>>>>>>
>>>>>> Kindly review the patch and let me know of the changes required.
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> Sathish V
>>>>>>
>>>>>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
>
> *Sr. Software Architect*
> *EnterpriseDB Software India Private Limited*
> *Mobile: +91 976-788-8246*
>


RM3669s3.patch
Description: Binary data


Reg - RM-5325[Code Coverage] Improve API test cases for Collations

2020-06-09 Thread Satish V
Hi Hackers,

Please find the attached patch which improves the code coverage for
Collations.
Without patch - 43%
With patch - 64%
Kindly review the patch and share the changes or improvements, if required.

Thanks,
Sathish V


RM5325v1.patch
Description: Binary data


Reg-[Sonarqube] - expects 4 arguments, but 5 were provided.

2020-06-12 Thread Satish V
Hi Hackers,

Attached is the patch which fixes the sonar issue of supplying more
parameters.
Kindly review and share the comments.


Thanks,
Sathish V


no_of_arg_fix.patch
Description: Binary data


Reg - [sonarqube] Refactor this code so that this expression does not always evaluate to true

2020-06-14 Thread Satish V
Hi Hackers,

Please find the patch in the attachment which clears the sonarqube error,
related to expressions evaluated to true/false always. Kindly review the
patch and share the changes required


Thanks,
Sathish V


refactor_always_evaluate_to_true.patch
Description: Binary data


Reg-[Sonarqube]CodeSmell issues

2020-06-16 Thread Satish V
Hi Hackers,

Please find the patch in the attachment which resolves below issues
1.Replace this if-then-else statement by a single return statement.(clumsy)
2."switch" statements should have at least 3 "case" clauses. (bad practise)
Kindly review and share the changes, if  required.


Thanks
Sathish V


switch_case_and_if_else_reduction.patch
Description: Binary data


Re-[Sonarqube]- Clumsy code

2020-06-17 Thread Satish V
Hi Hackers,

Please find the patch in the attachment which resolves below issue.
1.Replace this if-then-else statement by a single return statement.

Kindy review and share the changes, if required

Thanks,
Sathish V


if_else_reduction.patch
Description: Binary data


Re: Re-[Sonarqube]- Clumsy code

2020-06-18 Thread Satish V
Hi Akshay,

Please find the updated Patch in the attachment which does not introduce
more code smell.

Thanks
Sathish V

On Thu, Jun 18, 2020 at 12:48 PM Akshay Joshi 
wrote:

> Hi Satish
>
> Fixes like below will create another code smell in SonarQube:
>
>- !(m.label == 'pg_global') should be *(m.label != 'pg_global')*
>- !(_.isUndefined(index) || index == '');
>- !(_.has(itemData, 'label') && itemData.label === '_RETURN');
>- .
>
> Please fix such errors correctly and resend the patch. Make sure
> functionality should work properly.
>
> On Thu, Jun 18, 2020 at 11:27 AM Satish V 
> wrote:
>
>> Hi Hackers,
>>
>> Please find the patch in the attachment which resolves below issue.
>> 1.Replace this if-then-else statement by a single return statement.
>>
>> Kindy review and share the changes, if required
>>
>> Thanks,
>> Sathish V
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
>
> *Sr. Software Architect*
> *EnterpriseDB Software India Private Limited*
> *Mobile: +91 976-788-8246*
>


if_else_reduction.patch
Description: Binary data


[pgAdmin][patch]SonarQube tagged clumsy

2020-06-21 Thread Satish V
Hi Hackers,

Please find the patch in the attachment which solves the problem related to
reducing if else statement to single return expression.
Kindly review and share the changes required..

Thanks,
Sathish V


if_else_reduction.patch
Description: Binary data


Reg-[pgAdmin4][Patch] - SonarQube - Extra semicolons should be removed and Method names should comply with a naming convention

2020-06-24 Thread Satish V
Hi Hackers,

Please find the patch which solves the problem related to extra semicolons
and function naming convention.

Please review.

Thanks,
Sathish V


scss_and_function_name.patch
Description: Binary data


Re- [SonarQube][patch]- tagged suspicious, convention

2020-06-25 Thread Satish V
Hi Hackers,

Please find the patch which resolves the SonarQube scan issue stated below.
1.Method/Field names should comply with a naming convention.
2.Conditionals should start on new lines


conditionals_and_rename.patch
Description: Binary data


Re- [SonarQube][patch]- codesmell

2020-06-29 Thread Satish V
Hi Hackers,

Please find the patch which fixes the code smell issues related to the rule
"Variables should not be shadowed".

Thanks,
Sathish V


Variables_should_not_be_shadowed.patch
Description: Binary data


Reg - [RM-3814] Backup dialog does not show details of error if file name box kept empty

2020-07-03 Thread Satish V
Hi Hackers,

Please find the patch in the attachment which resolves the issue of error
messages not getting displayed in the dialog boxes of *backup, restore *and
*import/export.*

Kindly review the patch.

Thanks,
Sathish V


RM3814vs1.patch
Description: Binary data


Re- SonarQube[Variables should not be shadowed]

2020-07-03 Thread Satish V
Hi Hackers,

Please find the patch which fixes some of the sonar qube issues related to
variable shadowing.

Thanks,
Sathish V


variable_shadow1.patch
Description: Binary data


Re- Patch for SonarQube issues

2020-07-06 Thread Satish V
Hi Hackers,

I have fixed some issues related to variable shadowing. Please find the
patch in the attachments.
Files changed import_export.js and maintenance.js

Thanks,
Sathish V


variable_shadow.patch
Description: Binary data


Re- [pgAdmin][SonarQube] Variables should not be shadowed

2020-07-09 Thread Satish V
Hi Hackers,

Please find the patch which fixes 10 issues related to the Variables should
not be shadowed.
Kindly review and share the comments.

Thanks,
Sathish V


variable_shadow2.patch
Description: Binary data


Re-[pgAdmin][RM-5323]

2020-07-13 Thread Satish V
Hi Hackers,

Please find the patch which improves the API test cases for Foreign Data
Wrappers.

Before patch - 46%
After Patch - 73%
Kindly review and share the changes if required.

Thanks,
Sathish V


RM5323s1.patch
Description: Binary data


[pgAdmin4][Patch] - SonarQube Fixes

2020-07-14 Thread Satish V
Hi Hackers,

Please find the patch which fixes sonarQube issues related to variable
shadowing.
Files altered - backgird.js, backgrid.pgadmin.js

Kindly review and share your feedback.

Thanks,
Sathish V


variableShadowing.patch
Description: Binary data


[pgAdmin 4 - Bug #5137] Focussing in and then out of numeric input enables the save button in dialog

2020-07-16 Thread Satish V
Hi Hackers,

Please find the patch which fixes the bug related to save-button getting
enabled on hitting
tab key/focusing in and out of the numeric field(empty/non-empty).
Kindly review the patch.

Thanks,
Sathish V


RM5137s1.patch
Description: Binary data


[pgAdmin 4 - Housekeeping #5336][Code Coverage] Improve API test cases for Types

2020-07-29 Thread Satish V
Hi Hackers,

Please find the patch attached which improves the code coverage percentage
of Types from 53% to 76%. Kindly review the patch.

Thanks,
Sathish V


RM5336s1.patch
Description: Binary data


[pgAdmin 4 - Housekeeping #5327][Code Coverage] Improve API test cases for Schemas and Catalog Objects

2020-07-31 Thread Satish V
Hi Hackers,

Please find the patch which improves the code coverage for Schema alone.
Kindly create another RM for the Catalog Objects. Please review the patch.

Thanks,
Sathish V


RM5327v1.patch
Description: Binary data


Autovacuum on Toast table

2021-09-21 Thread satish v
Hi,
We deleted the old data around 300GB from a table.i can see the auto vacuum
performing on base table but not on toast table.due to this  db size is
growing rapidly. I am using the Azure PostgreSQL service.
In the base/parent table dead tuples are zero. Is  it possible to run the
vacuum on toast tables?.

Thanks in advance

[image: image.png]