From 2e29f3fd6d26542df7ea3d684960c69de1039db8 Mon Sep 17 00:00:00 2001 From: Satish V Date: Thu, 23 Apr 2020 16:42:42 +0530 Subject: [PATCH] =?UTF-8?q?Fixed=20an=20issue=20where=20columns=20names=20?= =?UTF-8?q?should=20be=20visible=20in=20the=20order=20of=20their=20creatio?= =?UTF-8?q?n=C2=A0in=20the=20browser=20tree.=20Fixes=20#5043?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en_US/release_notes_4_21.rst | 1 + web/pgadmin/browser/static/js/browser.js | 46 ++++++++++++++---------- web/pgadmin/static/js/pgadmin.js | 9 +++++ 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/docs/en_US/release_notes_4_21.rst b/docs/en_US/release_notes_4_21.rst index 78f1fd873..57411dd03 100644 --- a/docs/en_US/release_notes_4_21.rst +++ b/docs/en_US/release_notes_4_21.rst @@ -53,6 +53,7 @@ Bug fixes | `Issue #4957 `_ - Ensure that Constraint Trigger, Deferrable, Deferred option should be disabled when the user selects EDB-SPL function for the trigger. | `Issue #4969 `_ - Fixed an issue where changing the values of columns with JSONB or JSON types to NULL. | `Issue #5007 `_ - Ensure index dropdown should have existing indexes while creating unique constraints. +| `Issue #5043 `_ - Fixed an issue where columns names should be visible in the order of their creation in the browser tree. | `Issue #5053 `_ - Fixed an issue where changing the columns in the existing view throws an error. | `Issue #5157 `_ - Ensure that default sort order should be using the primary key in View/Edit data. | `Issue #5180 `_ - Fixed an issue where the autovacuum_enabled parameter is added automatically in the RE-SQL when the table has been created using the WITH clause. diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index 56a645e40..4ed30a26a 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -1001,12 +1001,13 @@ 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 +1027,31 @@ 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 true; + } 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 68a86af8b..aed6627ee 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. *