[pgAdmin4][patch] Remove extra brackets in CREATE Script and DDL Comparison

2021-07-06 Thread zhangj...@fujitsu.com
Hi, all

Extra brackets appear in CREATE Script and DDL Comparison,
please refer to the attachment error1.png and error2.png for details.

■ scenario
The step is as follow:
1) Connect to pg9.6 or pg9.5
2) The SQL to create the trigger is as follows.
-
CREATE TRIGGER tg1
BEFORE INSERT
ON public.tb1
FOR EACH ROW
WHEN (new.c1 > 0)
EXECUTE PROCEDURE public.tf1();
-

3) Right click  tg1
4) Click CREATE Script

The SQL shown in 'Query Editor' is as follows.
-
CREATE TRIGGER tg1
BEFORE INSERT
ON public.tb1
FOR EACH ROW
WHEN ((new.c1 > 0))   brackets appears twice.
EXECUTE PROCEDURE public.tf1();


■ The detail of cause:
file: 
web\pgadmin\browser\server_groups\servers\databases\schemas\tables\templates\triggers\sql\pg\default\create.sql

WHEN ({{ data.whenclause }}){% endif %}

There are already brackets in data.whenclause.

■ The summary of correction
file: 
web\pgadmin\browser\server_groups\servers\databases\schemas\tables\templates\triggers\sql\pg\default\create.sql
- WHEN ({{ data.whenclause }}){% endif %}
+ WHEN {% if not data.oid %}({% endif %}{{ data.whenclause }}{% if not data.oid 
%}){% endif %}{% endif %}

Refer to the following code for the correction method.
file: 
web\pgadmin\browser\server_groups\servers\databases\schemas\tables\templates\triggers\sql\pg\10_plus\create.sql
WHEN {% if not data.oid %}({% endif %}{{ data.whenclause }}{% if not data.oid 
%}){% endif %}{% endif %}

Here is a patch for create.sql
Please review.

Best Regards!
Zhangjie





create_sql.patch
Description: create_sql.patch


[pgAdmin4][patch] In SharedServersGetTestCase, the prompt information is wrong

2021-07-22 Thread zhangj...@fujitsu.com
Hi, all

SharedServersGetTestCase can only be tested in SERVER mode.
So, in Desktop mode, prompt information will be output.
However, the prompt is wrong.  
("Can not run shared servers test cases in the SERVER mode.")

I think it should be changed to the following prompt information
"Can not run shared servers test cases in the Desktop mode."


file: web\pgadmin\browser\server_groups\servers\tests\test_shared_server.py

SharedServersGetTestCase

def setUp(self):
"""This function add the server to test the GET API"""

if config.SERVER_MODE is False:
self.skipTest(
"Can not run shared servers test cases in the SERVER mode."  ※
)


Here is a patch for test_shared_server.py
Please review.

Best Regards!
Zhangjie





fix_test_shared_server.patch
Description: fix_test_shared_server.patch


[pgAdmin4] Questions about trigger properties's Fires in edit mode

2021-07-29 Thread zhangj...@fujitsu.com
Hi, all

In trigger's Properties screen, the 'fires' is disabled.
What is the reason why 'fires' is disabled?
I think it should be the same as 'evnt_insert',
When server_type is ppas and in edit mode, 'fires' is disabled.

file: 
web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js

 id: 'fires', label: gettext('Fires'), deps: ['is_constraint_trigger'],
  mode: ['create','edit', 'properties'], group: gettext('Events'),

disabled: function(m) {
if (!m.isNew()) ★ In edit mode, 'fires' is disabled.
  return true;  
// If contraint trigger is set to True then only enable it
var is_constraint_trigger = m.get('is_constraint_trigger');
if(!m.inSchemaWithModelCheck.apply(this, [m])) {
  if(!_.isUndefined(is_constraint_trigger) &&
is_constraint_trigger === true) {
setTimeout(function() { m.set('fires', 'AFTER'); }, 10);
return true;
  } else {
return false;
  }
} else {
  // Check if it is row trigger then enabled it.
  var fires_ = m.get('fires');
  if (!_.isUndefined(fires_) && 
m.node_info['server']['server_type'] == 'ppas') {
return false;
  }
  // Disable it
  return true;
}




[pgAdmin4][patch] error message is incorrect in domains

2021-09-27 Thread zhangj...@fujitsu.com
Hi, all

In domains's create function, res is used for all error messages.
I don't think this is correct.
On line 13, doid should be used as the error message.Because the execution 
result of line 11 is doid.
On line 21, scid should be used as the error message.Because the execution 
result of line 19 is scid.
There are similar problems in other functions.
Here is a patch for domains.
Please review.

file: 
pgadmin4\web\pgadmin\browser\server_groups\servers\databases\schemas\domains\__init__.py

   def create(self, gid, sid, did, scid):
..
 1   status, res = self.conn.execute_scalar(SQL)   
 2   if not status:
 3   return internal_server_error(errormsg=res) ※1   res is OK
 4
 5   # We need oid to add object in tree at browser, below sql will
 6   # gives the same
 7   SQL = render_template("/".join([self.template_path,
 8   self._OID_SQL]),
 9 basensp=data['basensp'],
 10 name=data['name'])
 11   status, doid = self.conn.execute_scalar(SQL)
 12   if not status:
 13   return internal_server_error(errormsg=res)   ※2  res => doid
 14
 15   # Get updated schema oid
 16   SQL = render_template("/".join([self.template_path,
 17   self._OID_SQL]),
 18 doid=doid)
 19   status, scid = self.conn.execute_scalar(SQL)
 20   if not status:
 21   return internal_server_error(errormsg=res)   ※3  res => scid 
--


domains.patch
Description: domains.patch


[pgAdmin4][patch] fix a typo in import_export_servers.rst

2021-12-09 Thread zhangj...@fujitsu.com
Hi, all

It seems like there's a following typo in import_export_servers.rst
-line option. There can be multiple configuations of pgAdmin on the same system.
+line option. There can be multiple configurations of pgAdmin on the same 
system.

Attaching a tiny patch to fix it. 
Please review.

Regards,
zhang jie

--
Development Department III
Software Division II
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
No.6 Wenzhu Road, Software Avenue, Nanjing, 210012, China
TEL  : +86+25-86630566-9353
COINS: 7998-9353
FAX  : +86+25-83317685
MAIL: zhangj...@fujitsu.com
FNST Oline:http://online.fnst.cn.fujitsu.com/fnst-news
-



import_export_servers.patch
Description: import_export_servers.patch


[PATCH] Change slash to backslash in make.bat

2022-02-15 Thread zhangj...@fujitsu.com
Hi, all

In windows, backslash should be used in the path. 
In Linux, slash should be used in path.
But in pgadmin4\make.bat, slash is used in the path.

FOR /f "tokens=1 DELims=." %%G IN ('%PGADMIN_PYTHON_DIR%/python.exe -c 
"print('%APP_NAME%'.lower().replace(' ', ''))"') DO SET APP_SHORTNAME=%%G

FOR /f "tokens=1 DELims=." %%G IN ('%PGADMIN_PYTHON_DIR%/python.exe -c "import 
sys; print(sys.version.split(' ')[0])"') DO SET PYTHON_MAJOR=%%G
FOR /f "tokens=2 DELims=." %%G IN ('%PGADMIN_PYTHON_DIR%/python.exe -c "import 
sys; print(sys.version.split(' ')[0])"') DO SET PYTHON_MINOR=%%G
FOR /f "tokens=3 DELims=." %%G IN ('%PGADMIN_PYTHON_DIR%/python.exe -c "import 
sys; print(sys.version.split(' ')[0])"') DO SET PYTHON_REVISION=%%G
--
Although the slash does not affect the compilation, I think it is better to 
modify it.

Here is a patch for make.bat.
Please review.

Best Regards!
Zhang Jie


make.patch
Description: make.patch