pgAdmin 4 commit: Add support in query history to show internal queries

2019-08-16 Thread Akshay Joshi
Add support in query history to show internal queries generated by pgAdmin 
during save data operations. Fixes #4612

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=687204771ce936697508997fb7988ad8551b9b81
Author: Yosry Muhammad 

Modified Files
--
docs/en_US/images/query_output_history.png | Bin 71494 -> 130318 bytes
docs/en_US/query_tool.rst  |   4 +
docs/en_US/release_notes_4_12.rst  |   1 +
web/pgadmin/feature_tests/locators.py  |   9 +
.../feature_tests/query_tool_journey_test.py   | 207 ++--
web/pgadmin/feature_tests/view_data_dml_queries.py |   3 +-
.../js/sqleditor/history/query_history_details.js  |  28 +-
.../js/sqleditor/history/query_history_entries.js  |  63 ++-
.../static/js/sqleditor/history/query_sources.js   |  35 ++
web/pgadmin/tools/sqleditor/__init__.py|   8 +-
.../tools/sqleditor/static/css/sqleditor.css   |   6 +-
.../tools/sqleditor/static/img/view_data.svg   |   9 +
web/pgadmin/tools/sqleditor/static/js/sqleditor.js | 122 +++--
.../tools/sqleditor/static/scss/_history.scss  |  29 +-
.../tools/sqleditor/utils/save_changed_data.py | 522 +++--
.../utils/tests/test_save_changed_data.py  |  39 +-
web/pgadmin/utils/driver/psycopg2/connection.py|  14 +
17 files changed, 724 insertions(+), 375 deletions(-)



Re: [GSoC] Query History Upgrade

2019-08-16 Thread Akshay Joshi
Thanks patch applied.

On Wed, Aug 14, 2019 at 7:24 PM Yosry Muhammad  wrote:

> Hi,
>
> On Wed, Aug 14, 2019 at 3:50 PM Yosry Muhammad  wrote:
>
>> Please find an updated patch with the mentioned issue fixed. I am sorry
>> you spent so much time reviewing this and finding bugs.
>>
>> On Wed, Aug 14, 2019 at 2:34 PM Akshay Joshi <
>> akshay.jo...@enterprisedb.com> wrote:
>>
>>> Hi Yosry
>>>
>>> I am still facing following issues:
>>>
>>>- No icons for already saved(before applying your patch) query in
>>>query history. Is this expected?
>>>
>>> I am sorry I missed this, yes this is expected as there is no way to
> identify internally generated queries before the patch.
> Thanks.
>


-- 
*Thanks & Regards*
*Akshay Joshi*

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


Re: [GSoC] Query History Upgrade

2019-08-16 Thread Yosry Muhammad
Thanks all for the thorough review.

On Fri, Aug 16, 2019, 1:48 PM Akshay Joshi 
wrote:

> Thanks patch applied.
>
> On Wed, Aug 14, 2019 at 7:24 PM Yosry Muhammad  wrote:
>
>> Hi,
>>
>> On Wed, Aug 14, 2019 at 3:50 PM Yosry Muhammad 
>> wrote:
>>
>>> Please find an updated patch with the mentioned issue fixed. I am sorry
>>> you spent so much time reviewing this and finding bugs.
>>>
>>> On Wed, Aug 14, 2019 at 2:34 PM Akshay Joshi <
>>> akshay.jo...@enterprisedb.com> wrote:
>>>
 Hi Yosry

 I am still facing following issues:

- No icons for already saved(before applying your patch) query in
query history. Is this expected?

 I am sorry I missed this, yes this is expected as there is no way to
>> identify internally generated queries before the patch.
>> Thanks.
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
>
> *Sr. Software Architect*
> *EnterpriseDB Software India Private Limited*
> *Mobile: +91 976-788-8246*
>


pgAdmin 4 commit: Add Reverse Engineered SQL tests for Columns. Fixes #

2019-08-16 Thread Akshay Joshi
Add Reverse Engineered SQL tests for Columns. Fixes #4546

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=3f541200d98ed754cb6fd3d2a1b3f07dc547762a
Author: Murtuza Zabuawala 

Modified Files
--
docs/en_US/release_notes_4_12.rst  |   1 +
.../columns/tests/10_plus/alter_column_char.sql|  11 +
.../tests/10_plus/alter_column_drop_identity.sql   |  11 +
.../alter_column_drop_identity_by_default.sql  |   9 +
.../tests/10_plus/alter_column_identity.sql|  11 +
.../10_plus/alter_column_identity_by_default.sql   |   9 +
.../columns/tests/10_plus/alter_column_int.sql |  11 +
.../columns/tests/10_plus/alter_column_numeric.sql |  15 +
.../columns/tests/10_plus/create_column_char.sql   |   9 +
.../columns/tests/10_plus/create_column_int.sql|   9 +
.../tests/10_plus/create_column_int_identity.sql   |   9 +
.../create_column_int_identity_by_default.sql  |   9 +
.../tests/10_plus/create_column_numeric.sql|  13 +
.../schemas/tables/columns/tests/10_plus/test.json | 279 ++
.../columns/tests/12_plus/alter_column_char.sql|  11 +
.../tests/12_plus/alter_column_drop_identity.sql   |  11 +
.../alter_column_drop_identity_by_default.sql  |   9 +
.../tests/12_plus/alter_column_generated.sql   |  11 +
...lter_column_generated_with_existing_columns.sql |  11 +
.../tests/12_plus/alter_column_identity.sql|  11 +
.../12_plus/alter_column_identity_by_default.sql   |   9 +
.../columns/tests/12_plus/alter_column_int.sql |  11 +
.../columns/tests/12_plus/alter_column_numeric.sql |  15 +
.../columns/tests/12_plus/create_column_char.sql   |   9 +
.../columns/tests/12_plus/create_column_int.sql|   9 +
.../tests/12_plus/create_column_int_generated.sql  |   9 +
..._column_int_generated_with_existing_columns.sql |   9 +
.../tests/12_plus/create_column_int_identity.sql   |   9 +
.../create_column_int_identity_by_default.sql  |   9 +
.../tests/12_plus/create_column_numeric.sql|  13 +
.../schemas/tables/columns/tests/12_plus/test.json | 407 +
.../columns/tests/default/alter_column_char.sql|  11 +
.../columns/tests/default/alter_column_int.sql |  11 +
.../columns/tests/default/alter_column_numeric.sql |  15 +
.../columns/tests/default/create_column_char.sql   |   9 +
.../columns/tests/default/create_column_int.sql|   9 +
.../tests/default/create_column_numeric.sql|  13 +
.../schemas/tables/columns/tests/default/test.json | 154 
.../tables/templates/columns/sql/9.1_plus/acl.sql  |   1 +
39 files changed, 1202 insertions(+)



Re: [RM#4546] Add RE-SQL tests for Column node

2019-08-16 Thread Akshay Joshi
Thanks patch applied.

On Fri, Aug 16, 2019 at 7:31 AM Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hello Akshay,
>
> On Fri, Aug 2, 2019 at 11:54 AM Akshay Joshi <
> akshay.jo...@enterprisedb.com> wrote:
>
>> Hi Murtuza
>>
>> Following test cases are missing:
>>
>>- Primary Key column.
>>
>> There is no provision to set Primary key from Column dialog, This test
> case will be covered with Primary key constraint RE-SQL tests.
>
>>
>>- Variable options.
>>
>> Added
>
>>
>>- Precision and Collation.
>>
>> Added
>
>>
>>- Identity column with 'GENERATED AS BY DEFAULT'.
>>
>> Added
>
>>
>>- ALTER column with identity values like CYCLE, minimum, maximum
>>etc.. instead of updating comments in such test cases.
>>
>> Fixed
>
>>
>>- Generated expression should use existing columns if possible like
>>(col1 * col2).
>>
>> Fixed
>
>
>> Apart from that can you please look into *RM #4500 *which seems minor
>> issue. Please send separate patch for both.
>>
>
> User is looking to provide length and precision for Integer type, which is
> not possible, We can close this RM.
>
>
> Please review the attached updated patch.
>
>
> Regards,
> Murtuza
>
>
>
>>
>> On Thu, Aug 1, 2019 at 5:36 PM Akshay Joshi <
>> akshay.jo...@enterprisedb.com> wrote:
>>
>>> Hi All
>>>
>>> I'll review this patch and give my review comments.
>>>
>>> On Wed, Jul 31, 2019 at 4:10 PM Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Hi,

 PFA patch to add RE-SQL tests for Column node.


 --
 Regards,
 Murtuza Zabuawala
 EnterpriseDB: http://www.enterprisedb.com
 The Enterprise PostgreSQL Company


>>>
>>> --
>>> *Thanks & Regards*
>>> *Akshay Joshi*
>>>
>>> *Sr. Software Architect*
>>> *EnterpriseDB Software India Private Limited*
>>> *Mobile: +91 976-788-8246*
>>>
>>
>>
>> --
>> *Thanks & Regards*
>> *Akshay Joshi*
>>
>> *Sr. Software Architect*
>> *EnterpriseDB Software India Private Limited*
>> *Mobile: +91 976-788-8246*
>>
>

-- 
*Thanks & Regards*
*Akshay Joshi*

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


pgAdmin 4 commit: Update message catalogs.

2019-08-16 Thread Akshay Joshi
Update message catalogs.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=177def1e580751198d60fad9a7bfe1bc1d271ff5

Modified Files
--
web/pgadmin/messages.pot   |  938 +
.../translations/de/LC_MESSAGES/messages.mo|  Bin 151201 -> 153699 bytes
.../translations/de/LC_MESSAGES/messages.po|  958 ++
.../translations/es/LC_MESSAGES/messages.mo|  Bin 155843 -> 158328 bytes
.../translations/es/LC_MESSAGES/messages.po|  960 ++
.../translations/fr/LC_MESSAGES/messages.mo|  Bin 172056 -> 163480 bytes
.../translations/fr/LC_MESSAGES/messages.po| 2011 +++-
.../translations/ja/LC_MESSAGES/messages.mo|  Bin 167950 -> 170370 bytes
.../translations/ja/LC_MESSAGES/messages.po|  960 ++
.../translations/ko/LC_MESSAGES/messages.mo|  Bin 153507 -> 155989 bytes
.../translations/ko/LC_MESSAGES/messages.po|  960 ++
.../translations/pl/LC_MESSAGES/messages.mo|  Bin 151230 -> 153726 bytes
.../translations/pl/LC_MESSAGES/messages.po|  958 ++
.../translations/ru/LC_MESSAGES/messages.mo|  Bin 187352 -> 189809 bytes
.../translations/ru/LC_MESSAGES/messages.po|  960 ++
.../translations/zh/LC_MESSAGES/messages.mo|  Bin 139465 -> 141807 bytes
.../translations/zh/LC_MESSAGES/messages.po|  454 +++--
17 files changed, 5230 insertions(+), 3929 deletions(-)



Release next week

2019-08-16 Thread Akshay Joshi
Hi Translators,

We will have release next week, so updates to translations prior to release
would be helpful. The template and catalogs have been updated in git.

-- 
*Thanks & Regards*
*Akshay Joshi*

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


Query Tool JS Minimal Refactoring

2019-08-16 Thread Yosry Muhammad
Hi hackers,

Please find attached a patch with minimal refactoring of:
web/pgadmin/tools/sqleditor/static/js/sqleditor.js

This includes merging 2 redundant functions into one and renaming some
functions to have more expressive and consistent names.

Please review !
Thanks.
-- 
*Yosry Muhammad Yosry*

Computer Engineering student,
The Faculty of Engineering,
Cairo University (2021).
Class representative of CMP 2021.
https://www.linkedin.com/in/yosrym93/
diff --git a/web/pgadmin/static/js/sqleditor/query_tool_actions.js b/web/pgadmin/static/js/sqleditor/query_tool_actions.js
index 18e15ecbe..34b6827ad 100644
--- a/web/pgadmin/static/js/sqleditor/query_tool_actions.js
+++ b/web/pgadmin/static/js/sqleditor/query_tool_actions.js
@@ -39,13 +39,8 @@ let queryToolActions = {
   },
 
   executeQuery: function (sqlEditorController) {
-if(sqlEditorController.is_query_tool) {
-  this._clearMessageTab();
-  sqlEditorController.execute();
-} else {
-  this._clearMessageTab();
-  sqlEditorController.execute_data_query();
-}
+this._clearMessageTab();
+sqlEditorController.check_data_changes_to_execute_query();
   },
 
   explainAnalyze: function (sqlEditorController) {
@@ -60,7 +55,7 @@ let queryToolActions = {
   settings: this._settings(),
 };
 this._clearMessageTab();
-sqlEditorController.execute(explainObject);
+sqlEditorController.check_data_changes_to_execute_query(explainObject);
   },
 
   explain: function (sqlEditorController) {
@@ -76,7 +71,7 @@ let queryToolActions = {
   settings: this._settings(),
 };
 this._clearMessageTab();
-sqlEditorController.execute(explainObject);
+sqlEditorController.check_data_changes_to_execute_query(explainObject);
   },
 
   download: function (sqlEditorController) {
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 4f387a5ce..669791190 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -2224,7 +2224,7 @@ define('tools.querytool', [
 cm.className += ' bg-gray-lighter opacity-5 hide-cursor-workaround';
   }
   self.disable_tool_buttons(true);
-  self.execute_data_query();
+  self.check_data_changes_to_execute_query();
 }
   },
 
@@ -2265,9 +2265,8 @@ define('tools.querytool', [
 self.on('pgadmin-sqleditor:unindent_selected_code', self._unindent_selected_code, self);
   },
 
-  // Checks if there is any dirty data in the grid before
-  // it executes the sql query in View Data mode
-  execute_data_query: function() {
+  // Checks if there is any dirty data in the grid before executing a query
+  check_data_changes_to_execute_query: function(explain_prefix=null, shouldReconnect=false) {
 var self = this;
 
 // Check if the data grid has any changes before running query
@@ -2279,8 +2278,13 @@ define('tools.querytool', [
   alertify.confirm(gettext('Unsaved changes'),
 gettext('The data has been modified, but not saved. Are you sure you wish to discard the changes?'),
 function() {
-  // Do nothing as user do not want to save, just continue
-  self._run_query();
+  // The user does not want to save, just continue
+  if(self.is_query_tool) {
+self._execute_sql_query(explain_prefix, shouldReconnect);
+  }
+  else {
+self._execute_view_data_query();
+  }
 },
 function() {
   // Stop, User wants to save
@@ -2291,12 +2295,17 @@ define('tools.querytool', [
 cancel: gettext('No'),
   });
 } else {
-  self._run_query();
+  if(self.is_query_tool) {
+self._execute_sql_query(explain_prefix, shouldReconnect);
+  }
+  else {
+self._execute_view_data_query();
+  }
 }
   },
 
-  // This function makes the ajax call to execute the sql query in View Data mode
-  _run_query: function() {
+  // Makes the ajax call to execute the sql query in View Data mode
+  _execute_view_data_query: function() {
 var self = this,
   url = url_for('sqleditor.view_data_start', {
 'trans_id': self.transId,
@@ -2373,12 +2382,36 @@ define('tools.querytool', [
   .fail(function(e) {
 self.trigger('pgadmin-sqleditor:loading-icon:hide');
 let msg = httpErrorHandler.handleQueryToolAjaxError(
-  pgAdmin, self, e, '_run_query', [], true
+  pgAdmin, self, e, '_execute_view_data_query', [], true
 );
 self.update_msg_history(false, msg);
   });
   },
 
+  // Executes sql query in the editor in Query Tool mode
+  _execute_sql_query: function(explain_prefix, shouldReconnect) {
+var