public inbox for [email protected]
help / color / mirror / Atom feed[patch] Dependents and Dependencies in GreenPlum
27+ messages / 8 participants
[nested] [flat]
* [patch] Dependents and Dependencies in GreenPlum
@ 2017-04-21 19:42 Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Joao Pedro De Almeida Pereira @ 2017-04-21 19:42 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
We found out that when you are connected to a GreenPlum database and try to
get Dependents and Dependencies of an object the application was returning
a SQL error.
This patch splits the SQL query used to retrieve the Dependents,
Dependencies, and Roles SQL file into multiple versioned files.
Add Unit Tests for each file.
Also added __init__.py files to other test directories to run the tests in
them.
Add ORDER BY into Copy Selection Feature test to ensure the results are
retrieved always in the same order
Renamed the Scenario of the xss_checks_pgadmin_debugger_test and skip it
for versions less than 9.1
Thanks
Joao & Sarah
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] 0001-Fix-error-while-checking-Dependents-and-Dependencies.patch (35.1K, 3-0001-Fix-error-while-checking-Dependents-and-Dependencies.patch)
download | inline diff:
From 0c21ff7a81b4421856a1bf1c7a495b55bd3ad1a6 Mon Sep 17 00:00:00 2001
From: Joao Pereira and Oliver Switzer <[email protected]>
Date: Tue, 18 Apr 2017 16:08:28 -0400
Subject: [PATCH] Fix error while checking Dependents and Dependencies of
object in GreenPlum: - Make SQL template UT visible to runtest - Add SQL to
retrieve dependencies for GreenPlum - Extract Role Dependencies from single
dependents file - Split template for dependents SQL - Add 'SET LOCAL
join_collapse_limit=8;' to dependency/dependents to make them faster. Only
caveat is that this will remain unchanged for the session - Add more
expectations to role dependencies - Specify order of query in
copy_selected_query_results_feature_test to make tests pass - GreenPlum
and Postgres order these results differently by default without an order
clause specified. - Skip XSS test for GreenPlum
---
.../tables/templates/column/sql/__init__.py | 6 ++
.../tables/templates/column/sql/tests/__init__.py | 6 ++
.../templates/column/sql/tests/test_column_acl.py | 4 ++
.../column/sql/tests/test_column_properties.py | 4 ++
.../schemas/tables/templates/trigger/__init__.py | 6 ++
.../trigger/sql/tests/test_trigger_get_oid.py | 4 +-
.../trigger/sql/tests/test_trigger_nodes.py | 3 +
.../servers/templates/depends/__init__.py | 6 ++
.../depends/sql/9.1_plus/dependencies.sql | 45 +++++++++++++++
.../templates/depends/sql/9.1_plus/dependents.sql | 44 +++++++++++++++
.../servers/templates/depends/sql/__init__.py | 6 ++
.../templates/depends/sql/default/dependencies.sql | 42 ++++++++++++++
.../templates/depends/sql/default/dependents.sql | 66 +---------------------
.../depends/sql/default/role_dependencies.sql | 4 ++
.../templates/depends/sql/tests/__init__.py | 6 ++
.../depends/sql/tests/test_dependencies.py | 58 +++++++++++++++++++
.../templates/depends/sql/tests/test_dependents.py | 58 +++++++++++++++++++
.../depends/sql/tests/test_role_dependencies.py | 54 ++++++++++++++++++
web/pgadmin/browser/utils.py | 10 ++--
.../copy_selected_query_results_feature_test.py | 2 +-
.../xss_checks_pgadmin_debugger_test.py | 6 +-
21 files changed, 369 insertions(+), 71 deletions(-)
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependencies.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependents.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_role_dependencies.py
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/__init__.py
new file mode 100644
index 00000000..9e55d2b2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/__init__.py
@@ -0,0 +1,6 @@
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/__init__.py
new file mode 100644
index 00000000..9e55d2b2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/__init__.py
@@ -0,0 +1,6 @@
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
index 7be945c7..68bccfc8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
@@ -13,6 +13,10 @@ if sys.version_info[0] >= 3:
class TestColumnAcl(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column ACL SQL file', dict())
+ ]
def runTest(self):
""" When there are no permissions on the column, it returns an empty result """
with test_utils.Database(self.server) as (connection, database_name):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
index b1984bda..3c3457b6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
@@ -22,6 +22,10 @@ if sys.version_info[0] >= 3:
class TestColumnProperties(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column Properties SQL file', dict())
+ ]
def runTest(self):
""" This tests that column properties are returned"""
with test_utils.Database(self.server) as (connection, database_name):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/__init__.py
new file mode 100644
index 00000000..9e55d2b2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/__init__.py
@@ -0,0 +1,6 @@
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
index f2b637ee..25ce845d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
@@ -24,8 +24,10 @@ if sys.version_info[0] >= 3:
class TestTriggerGetOid(BaseTestGenerator):
+ scenarios = [
+ ('Test Trigger to retrieve OID SQL file', dict())
+ ]
def runTest(self):
- """ When there are no permissions on the column, it returns an empty result """
with test_utils.Database(self.server) as (connection, database_name):
test_utils.create_table(self.server, database_name, "test_table")
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
index b23bf60a..b82d85d4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
@@ -22,6 +22,9 @@ if sys.version_info[0] >= 3:
class TestTriggerNodes(BaseTestGenerator):
+ scenarios = [
+ ('Test Trigger Nodes SQL file', dict())
+ ]
def runTest(self):
""" When there are no triggers, it returns an empty result """
with test_utils.Database(self.server) as (connection, database_name):
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/__init__.py b/web/pgadmin/browser/server_groups/servers/templates/depends/__init__.py
new file mode 100644
index 00000000..9e55d2b2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/__init__.py
@@ -0,0 +1,6 @@
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
new file mode 100644
index 00000000..e5bb8cb6
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
@@ -0,0 +1,45 @@
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
new file mode 100644
index 00000000..1281672f
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
@@ -0,0 +1,44 @@
+SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL THEN 'y'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.objid=cl.oid
+LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.objid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.objid=tg.oid
+LEFT JOIN pg_type ty ON dep.objid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.objid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.objid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.objid=la.oid
+LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
+{{where_clause}} AND
+classid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY classid, cl.relkind
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/__init__.py
new file mode 100644
index 00000000..9e55d2b2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/__init__.py
@@ -0,0 +1,6 @@
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
new file mode 100644
index 00000000..aae5982e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
@@ -0,0 +1,42 @@
+SET LOCAL join_collapse_limit=8;
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
index e2ba3d6b..2fe2ef3e 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
@@ -1,59 +1,4 @@
-{% if fetch_dependencies %}
-SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
- CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
- WHEN tg.oid IS NOT NULL THEN 'T'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
- WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
- WHEN la.oid IS NOT NULL THEN 'l'::text
- WHEN rw.oid IS NOT NULL THEN 'R'::text
- WHEN co.oid IS NOT NULL THEN 'C'::text || contype
- WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
- ELSE ''
- END AS type,
- COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
- END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
-FROM pg_depend dep
-LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
-LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
-LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
-LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
-LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
-LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
-LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
-LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
-LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
-LEFT JOIN pg_class coc ON co.conrelid=coc.oid
-LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
-LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
-LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
-LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
-LEFT JOIN pg_language la ON dep.refobjid=la.oid
-LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
-LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
-{{where_clause}} AND
-refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
- ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
- 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY refclassid, cl.relkind
-{% endif %}
-
-{% if fetch_role_dependencies %}
-SELECT rolname AS refname, refclassid, deptype
-FROM pg_shdepend dep
-LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
-{{where_clause}} ORDER BY 1
-{% endif %}
-
-{% if fetch_dependents %}
+SET LOCAL join_collapse_limit=8;
SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
WHEN tg.oid IS NOT NULL THEN 'T'::text
@@ -64,13 +9,11 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
END AS refname,
COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
FROM pg_depend dep
@@ -91,11 +34,8 @@ LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
LEFT JOIN pg_language la ON dep.objid=la.oid
LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
{{where_clause}} AND
classid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY classid, cl.relkind
-{% endif %}
+ORDER BY classid, cl.relkind;
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
new file mode 100644
index 00000000..25fc3f85
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
@@ -0,0 +1,4 @@
+SELECT rolname AS refname, refclassid, deptype
+FROM pg_shdepend dep
+LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
+{{where_clause}} ORDER BY 1
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/__init__.py
new file mode 100644
index 00000000..f64f8973
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/__init__.py
@@ -0,0 +1,6 @@
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependencies.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependencies.py
new file mode 100644
index 00000000..ce1f97d9
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependencies.py
@@ -0,0 +1,58 @@
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+import os
+import sys
+
+from pgadmin.utils.driver import DriverRegistry
+from regression.python_test_utils.template_helper import file_as_template
+
+DriverRegistry.load_drivers()
+from pgadmin.utils.route import BaseTestGenerator
+from regression.python_test_utils import test_utils
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestDependencies(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+ def runTest(self):
+ """ When there are no permissions on the column, it returns an empty result """
+ with test_utils.Database(self.server) as (connection, database_name):
+ test_utils.create_table(self.server, database_name, "test_table")
+
+ cursor = connection.cursor()
+ cursor.execute("SELECT pg_class.oid as table_id "
+ "FROM pg_class "
+ "where pg_class.relname='test_table'")
+ table_id = cursor.fetchone()
+
+ if connection.server_version < 90100:
+ self.versions_to_test = ['default']
+ else:
+ self.versions_to_test = ['9.1_plus']
+
+ for version in self.versions_to_test:
+ template_file = os.path.join(os.path.dirname(__file__), "..", version, "dependencies.sql")
+ template = file_as_template(template_file)
+
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % table_id)
+
+ cursor = connection.cursor()
+ cursor.execute(sql)
+ fetch_result = cursor.fetchall()
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(cursor.description):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('public', first_row["refname"])
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependents.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependents.py
new file mode 100644
index 00000000..0bd4c960
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependents.py
@@ -0,0 +1,58 @@
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+import os
+import sys
+
+from pgadmin.utils.driver import DriverRegistry
+from regression.python_test_utils.template_helper import file_as_template
+
+DriverRegistry.load_drivers()
+from pgadmin.utils.route import BaseTestGenerator
+from regression.python_test_utils import test_utils
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestDependencies(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+ def runTest(self):
+ """ When there are no permissions on the column, it returns an empty result """
+ with test_utils.Database(self.server) as (connection, database_name):
+ test_utils.create_table(self.server, database_name, "test_table")
+
+ cursor = connection.cursor()
+ cursor.execute("SELECT pg_class.oid as table_id "
+ "FROM pg_class "
+ "where pg_class.relname='test_table'")
+ table_id = cursor.fetchone()
+
+ if connection.server_version < 90100:
+ self.versions_to_test = ['default']
+ else:
+ self.versions_to_test = ['9.1_plus']
+
+ for version in self.versions_to_test:
+ template_file = os.path.join(os.path.dirname(__file__), "..", version, "dependents.sql")
+ template = file_as_template(template_file)
+
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % table_id)
+
+ cursor = connection.cursor()
+ cursor.execute(sql)
+ fetch_result = cursor.fetchall()
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(cursor.description):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('test_table', first_row["refname"])
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_role_dependencies.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_role_dependencies.py
new file mode 100644
index 00000000..7c9a0b03
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_role_dependencies.py
@@ -0,0 +1,54 @@
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+import os
+import sys
+
+from pgadmin.utils.driver import DriverRegistry
+from regression.python_test_utils.template_helper import file_as_template
+
+DriverRegistry.load_drivers()
+from pgadmin.utils.route import BaseTestGenerator
+from regression.python_test_utils import test_utils
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestRoleDependencies(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Role Dependencies SQL file', dict())
+ ]
+ def runTest(self):
+ """ When there are no Role Dependencies on the table, it returns an empty result """
+ with test_utils.Database(self.server) as (connection, database_name):
+ test_utils.create_table(self.server, database_name, "test_table")
+
+ cursor = connection.cursor()
+ cursor.execute("SELECT pg_class.oid as table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ table_id = cursor.fetchone()
+
+ self.versions_to_test = ['default']
+
+ for version in self.versions_to_test:
+ template_file = os.path.join(os.path.dirname(__file__), "..", version, "role_dependencies.sql")
+ template = file_as_template(template_file)
+
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % table_id)
+
+ cursor = connection.cursor()
+ cursor.execute(sql)
+ fetch_result = cursor.fetchall()
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(cursor.description):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('o', first_row["deptype"])
diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
index d2899875..708bfdfb 100644
--- a/web/pgadmin/browser/utils.py
+++ b/web/pgadmin/browser/utils.py
@@ -353,15 +353,15 @@ class PGChildNodeView(NodeView):
else:
where_clause = where
- query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependencies=True, where_clause=where_clause)
+ query = render_template("/".join([sql_path, 'dependencies.sql']),
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependencies = self.__fetch_dependency(conn, query)
# fetch role dependencies
if where_clause.find('subid') < 0:
- sql = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_role_dependencies=True, where_clause=where_clause)
+ sql = render_template("/".join([sql_path, 'role_dependencies.sql']),
+ where_clause=where_clause)
status, result = conn.execute_dict(sql)
if not status:
@@ -402,7 +402,7 @@ class PGChildNodeView(NodeView):
where_clause = where
query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependents=True, where_clause=where_clause)
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependents = self.__fetch_dependency(conn, query)
diff --git a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
index 223579ee..bda9de22 100644
--- a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
+++ b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
@@ -37,7 +37,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
self.page.find_by_partial_link_text("Query Tool").click()
self.page.click_tab('Query-1')
time.sleep(5)
- ActionChains(self.page.driver).send_keys("SELECT * FROM test_table").perform()
+ ActionChains(self.page.driver).send_keys("SELECT * FROM test_table ORDER BY some_column").perform()
self.page.driver.switch_to_frame(self.page.driver.find_element_by_tag_name("iframe"))
self.page.find_by_id("btn-flash").click()
diff --git a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
index 8b018fed..17bc7bf5 100644
--- a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
+++ b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
@@ -16,10 +16,14 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest):
"""Tests to check if Debugger is vulnerable to XSS."""
scenarios = [
- ("Test table DDL generation", dict())
+ ("Tests to check if Debugger is vulnerable to XSS", dict())
]
def before(self):
+ with test_utils.Database(self.server) as (connection, _):
+ if connection.server_version < 90100:
+ self.skipTest("Functions tree node is not present in pgAdmin below PG v9.1")
+
# Some test function is needed for debugger
test_utils.create_debug_function(self.server, "postgres",
"test_function")
--
2.12.0
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
@ 2017-04-24 11:13 ` Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Dave Page @ 2017-04-24 11:13 UTC (permalink / raw)
To: Joao Pedro De Almeida Pereira <[email protected]>; +Cc: pgadmin-hackers; Ashesh Vashi <[email protected]>
Ashesh, can you review/commit this please?
On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
[email protected]> wrote:
> Hi Hackers,
>
> We found out that when you are connected to a GreenPlum database and try
> to get Dependents and Dependencies of an object the application was
> returning a SQL error.
>
> This patch splits the SQL query used to retrieve the Dependents,
> Dependencies, and Roles SQL file into multiple versioned files.
> Add Unit Tests for each file.
> Also added __init__.py files to other test directories to run the tests in
> them.
> Add ORDER BY into Copy Selection Feature test to ensure the results are
> retrieved always in the same order
> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and skip it
> for versions less than 9.1
>
> Thanks
>
> Joao & Sarah
>
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
@ 2017-04-26 05:26 ` Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Ashesh Vashi @ 2017-04-26 05:26 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: Joao Pedro De Almeida Pereira <[email protected]>; pgadmin-hackers
On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]> wrote:
> Ashesh, can you review/commit this please?
>
> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
> [email protected]> wrote:
>
>> Hi Hackers,
>>
>> We found out that when you are connected to a GreenPlum database and try
>> to get Dependents and Dependencies of an object the application was
>> returning a SQL error.
>>
>> This patch splits the SQL query used to retrieve the Dependents,
>> Dependencies, and Roles SQL file into multiple versioned files.
>> Add Unit Tests for each file.
>> Also added __init__.py files to other test directories to run the tests
>> in them.
>>
> Hi Joao & Sarah,
Why do we need to add __init__.py in the template directory?
I didn't understand the purpose of the adding __init__.py files in the
template directories.
NOTE: The headers in those files are not consistent with the other project
files.
--
Thanks & Regards,
Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company
<http://www.enterprisedb.com/;
*http://www.linkedin.com/in/asheshvashi*
<http://www.linkedin.com/in/asheshvashi;
> Add ORDER BY into Copy Selection Feature test to ensure the results are
>> retrieved always in the same order
>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and skip it
>> for versions less than 9.1
>>
>> Thanks
>>
>> Joao & Sarah
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list ([email protected])
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
@ 2017-04-26 15:22 ` Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Joao Pedro De Almeida Pereira @ 2017-04-26 15:22 UTC (permalink / raw)
To: Ashesh Vashi <[email protected]>; +Cc: Dave Page <[email protected]>; pgadmin-hackers
Hello Ashesh,
Thanks for reviewing the patch.
We added the __init__.py files into templates to convert them into packages
so that the tests inside of them can be found by the test runner.
Thanks!
Joao & Sarah
On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <[email protected]
> wrote:
> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]> wrote:
>
>> Ashesh, can you review/commit this please?
>>
>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>> [email protected]> wrote:
>>
>>> Hi Hackers,
>>>
>>> We found out that when you are connected to a GreenPlum database and try
>>> to get Dependents and Dependencies of an object the application was
>>> returning a SQL error.
>>>
>>> This patch splits the SQL query used to retrieve the Dependents,
>>> Dependencies, and Roles SQL file into multiple versioned files.
>>> Add Unit Tests for each file.
>>> Also added __init__.py files to other test directories to run the tests
>>> in them.
>>>
>> Hi Joao & Sarah,
>
> Why do we need to add __init__.py in the template directory?
> I didn't understand the purpose of the adding __init__.py files in the
> template directories.
>
> NOTE: The headers in those files are not consistent with the other project
> files.
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com/;
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi;
>
>> Add ORDER BY into Copy Selection Feature test to ensure the results are
>>> retrieved always in the same order
>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and skip
>>> it for versions less than 9.1
>>>
>>> Thanks
>>>
>>> Joao & Sarah
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list ([email protected])
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
@ 2017-04-27 14:37 ` Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Joao Pedro De Almeida Pereira @ 2017-04-27 14:37 UTC (permalink / raw)
To: Ashesh Vashi <[email protected]>; +Cc: Dave Page <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Thanks for reviewing, Ashesh.
We have updated the patch. The headers are all consistent and we removed
the __init__.py files in directories containing only .sql.
Thanks!
Joao & Matt
On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
[email protected]> wrote:
> Hello Ashesh,
>
> Thanks for reviewing the patch.
>
> We added the __init__.py files into templates to convert them into
> packages so that the tests inside of them can be found by the test runner.
>
> Thanks!
> Joao & Sarah
>
> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
> [email protected]> wrote:
>
>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]> wrote:
>>
>>> Ashesh, can you review/commit this please?
>>>
>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>>> [email protected]> wrote:
>>>
>>>> Hi Hackers,
>>>>
>>>> We found out that when you are connected to a GreenPlum database and
>>>> try to get Dependents and Dependencies of an object the application was
>>>> returning a SQL error.
>>>>
>>>> This patch splits the SQL query used to retrieve the Dependents,
>>>> Dependencies, and Roles SQL file into multiple versioned files.
>>>> Add Unit Tests for each file.
>>>> Also added __init__.py files to other test directories to run the tests
>>>> in them.
>>>>
>>> Hi Joao & Sarah,
>>
>> Why do we need to add __init__.py in the template directory?
>> I didn't understand the purpose of the adding __init__.py files in the
>> template directories.
>>
>> NOTE: The headers in those files are not consistent with the other
>> project files.
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> <http://www.enterprisedb.com/;
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> <http://www.linkedin.com/in/asheshvashi;
>>
>>> Add ORDER BY into Copy Selection Feature test to ensure the results are
>>>> retrieved always in the same order
>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and skip
>>>> it for versions less than 9.1
>>>>
>>>> Thanks
>>>>
>>>> Joao & Sarah
>>>>
>>>>
>>>> --
>>>> Sent via pgadmin-hackers mailing list ([email protected])
>>>> To make changes to your subscription:
>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>
>>>>
>>>
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] 0001-Fix-error-while-checking-Dependents-and-Dependencies.patch (42.2K, 3-0001-Fix-error-while-checking-Dependents-and-Dependencies.patch)
download | inline diff:
From e94b439ddc672639dc63134b6ce877046533aa71 Mon Sep 17 00:00:00 2001
From: Joao Pereira and Oliver Switzer <[email protected]>
Date: Tue, 18 Apr 2017 16:08:28 -0400
Subject: [PATCH] Fix error while checking Dependents and Dependencies of
object in GreenPlum: - Make SQL template UT visible to runtest - Add SQL to
retrieve dependencies for GreenPlum - Extract Role Dependencies from single
dependents file - Split template for dependents SQL - Add 'SET LOCAL
join_collapse_limit=8;' to dependency/dependents to make them faster. Only
caveat is that this will remain unchanged for the session - Add more
expectations to role dependencies - Specify order of query in
copy_selected_query_results_feature_test to make tests pass - GreenPlum and
Postgres order these results differently by default without an order clause
specified. - Skip XSS test for GreenPlum
---
.../databases/schemas/tables/templates/__init__.py | 8 +++
.../schemas/tables/templates/column/__init__.py | 8 +++
.../templates/column/sql/9.2_plus/__init__.py | 0
.../tables/templates/column/sql/__init__.py | 8 +++
.../templates/column/sql/default/__init__.py | 0
.../tables/templates/column/sql/tests/__init__.py | 8 +++
.../templates/column/sql/tests/test_column_acl.py | 13 +++++
.../column/sql/tests/test_column_properties.py | 4 ++
.../schemas/tables/templates/trigger/__init__.py | 8 +++
.../templates/trigger/sql/9.1_plus/__init__.py | 0
.../tables/templates/trigger/sql/__init__.py | 8 +++
.../templates/trigger/sql/default/__init__.py | 0
.../tables/templates/trigger/sql/tests/__init__.py | 8 +++
.../trigger/sql/tests/test_trigger_get_oid.py | 4 +-
.../trigger/sql/tests/test_trigger_nodes.py | 3 +
.../servers/templates/depends/__init__.py | 8 +++
.../depends/sql/9.1_plus/dependencies.sql | 45 +++++++++++++++
.../templates/depends/sql/9.1_plus/dependents.sql | 44 +++++++++++++++
.../servers/templates/depends/sql/__init__.py | 8 +++
.../templates/depends/sql/default/dependencies.sql | 42 ++++++++++++++
.../templates/depends/sql/default/dependents.sql | 66 +---------------------
.../depends/sql/default/role_dependencies.sql | 4 ++
.../templates/depends/sql/tests/__init__.py | 8 +++
.../depends/sql/tests/test_dependencies.py | 61 ++++++++++++++++++++
.../templates/depends/sql/tests/test_dependents.py | 61 ++++++++++++++++++++
.../depends/sql/tests/test_role_dependencies.py | 57 +++++++++++++++++++
web/pgadmin/browser/utils.py | 10 ++--
.../copy_selected_query_results_feature_test.py | 11 +++-
.../xss_checks_pgadmin_debugger_test.py | 6 +-
29 files changed, 440 insertions(+), 71 deletions(-)
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/__init__.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependencies.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependents.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_role_dependencies.py
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py
index e69de29b..78275c25 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py
index e69de29b..78275c25 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/__init__.py
new file mode 100644
index 00000000..78275c25
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/__init__.py
new file mode 100644
index 00000000..78275c25
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
index 7be945c7..a7fa0c48 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
@@ -1,3 +1,12 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
import os
import sys
@@ -13,6 +22,10 @@ if sys.version_info[0] >= 3:
class TestColumnAcl(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column ACL SQL file', dict())
+ ]
def runTest(self):
""" When there are no permissions on the column, it returns an empty result """
with test_utils.Database(self.server) as (connection, database_name):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
index b1984bda..3c3457b6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
@@ -22,6 +22,10 @@ if sys.version_info[0] >= 3:
class TestColumnProperties(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column Properties SQL file', dict())
+ ]
def runTest(self):
""" This tests that column properties are returned"""
with test_utils.Database(self.server) as (connection, database_name):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/__init__.py
new file mode 100644
index 00000000..78275c25
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py
index e69de29b..78275c25 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py
index e69de29b..78275c25 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
index f2b637ee..25ce845d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
@@ -24,8 +24,10 @@ if sys.version_info[0] >= 3:
class TestTriggerGetOid(BaseTestGenerator):
+ scenarios = [
+ ('Test Trigger to retrieve OID SQL file', dict())
+ ]
def runTest(self):
- """ When there are no permissions on the column, it returns an empty result """
with test_utils.Database(self.server) as (connection, database_name):
test_utils.create_table(self.server, database_name, "test_table")
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
index b23bf60a..b82d85d4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
@@ -22,6 +22,9 @@ if sys.version_info[0] >= 3:
class TestTriggerNodes(BaseTestGenerator):
+ scenarios = [
+ ('Test Trigger Nodes SQL file', dict())
+ ]
def runTest(self):
""" When there are no triggers, it returns an empty result """
with test_utils.Database(self.server) as (connection, database_name):
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/__init__.py b/web/pgadmin/browser/server_groups/servers/templates/depends/__init__.py
new file mode 100644
index 00000000..78275c25
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
new file mode 100644
index 00000000..e5bb8cb6
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
@@ -0,0 +1,45 @@
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
new file mode 100644
index 00000000..1281672f
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
@@ -0,0 +1,44 @@
+SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL THEN 'y'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.objid=cl.oid
+LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.objid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.objid=tg.oid
+LEFT JOIN pg_type ty ON dep.objid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.objid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.objid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.objid=la.oid
+LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
+{{where_clause}} AND
+classid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY classid, cl.relkind
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/__init__.py
new file mode 100644
index 00000000..78275c25
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
new file mode 100644
index 00000000..aae5982e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
@@ -0,0 +1,42 @@
+SET LOCAL join_collapse_limit=8;
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
index e2ba3d6b..2fe2ef3e 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
@@ -1,59 +1,4 @@
-{% if fetch_dependencies %}
-SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
- CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
- WHEN tg.oid IS NOT NULL THEN 'T'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
- WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
- WHEN la.oid IS NOT NULL THEN 'l'::text
- WHEN rw.oid IS NOT NULL THEN 'R'::text
- WHEN co.oid IS NOT NULL THEN 'C'::text || contype
- WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
- ELSE ''
- END AS type,
- COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
- END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
-FROM pg_depend dep
-LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
-LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
-LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
-LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
-LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
-LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
-LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
-LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
-LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
-LEFT JOIN pg_class coc ON co.conrelid=coc.oid
-LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
-LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
-LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
-LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
-LEFT JOIN pg_language la ON dep.refobjid=la.oid
-LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
-LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
-{{where_clause}} AND
-refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
- ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
- 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY refclassid, cl.relkind
-{% endif %}
-
-{% if fetch_role_dependencies %}
-SELECT rolname AS refname, refclassid, deptype
-FROM pg_shdepend dep
-LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
-{{where_clause}} ORDER BY 1
-{% endif %}
-
-{% if fetch_dependents %}
+SET LOCAL join_collapse_limit=8;
SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
WHEN tg.oid IS NOT NULL THEN 'T'::text
@@ -64,13 +9,11 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
END AS refname,
COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
FROM pg_depend dep
@@ -91,11 +34,8 @@ LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
LEFT JOIN pg_language la ON dep.objid=la.oid
LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
{{where_clause}} AND
classid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY classid, cl.relkind
-{% endif %}
+ORDER BY classid, cl.relkind;
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
new file mode 100644
index 00000000..25fc3f85
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
@@ -0,0 +1,4 @@
+SELECT rolname AS refname, refclassid, deptype
+FROM pg_shdepend dep
+LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
+{{where_clause}} ORDER BY 1
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/__init__.py
new file mode 100644
index 00000000..78275c25
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/__init__.py
@@ -0,0 +1,8 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependencies.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependencies.py
new file mode 100644
index 00000000..e6451bbb
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependencies.py
@@ -0,0 +1,61 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+import sys
+
+from pgadmin.utils.driver import DriverRegistry
+from regression.python_test_utils.template_helper import file_as_template
+
+DriverRegistry.load_drivers()
+from pgadmin.utils.route import BaseTestGenerator
+from regression.python_test_utils import test_utils
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestDependencies(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+ def runTest(self):
+ """ When there are no permissions on the column, it returns an empty result """
+ with test_utils.Database(self.server) as (connection, database_name):
+ test_utils.create_table(self.server, database_name, "test_table")
+
+ cursor = connection.cursor()
+ cursor.execute("SELECT pg_class.oid as table_id "
+ "FROM pg_class "
+ "where pg_class.relname='test_table'")
+ table_id = cursor.fetchone()
+
+ if connection.server_version < 90100:
+ self.versions_to_test = ['default']
+ else:
+ self.versions_to_test = ['9.1_plus']
+
+ for version in self.versions_to_test:
+ template_file = os.path.join(os.path.dirname(__file__), "..", version, "dependencies.sql")
+ template = file_as_template(template_file)
+
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % table_id)
+
+ cursor = connection.cursor()
+ cursor.execute(sql)
+ fetch_result = cursor.fetchall()
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(cursor.description):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('public', first_row["refname"])
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependents.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependents.py
new file mode 100644
index 00000000..41b8f8c3
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_dependents.py
@@ -0,0 +1,61 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+import sys
+
+from pgadmin.utils.driver import DriverRegistry
+from regression.python_test_utils.template_helper import file_as_template
+
+DriverRegistry.load_drivers()
+from pgadmin.utils.route import BaseTestGenerator
+from regression.python_test_utils import test_utils
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestDependencies(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+ def runTest(self):
+ """ When there are no permissions on the column, it returns an empty result """
+ with test_utils.Database(self.server) as (connection, database_name):
+ test_utils.create_table(self.server, database_name, "test_table")
+
+ cursor = connection.cursor()
+ cursor.execute("SELECT pg_class.oid as table_id "
+ "FROM pg_class "
+ "where pg_class.relname='test_table'")
+ table_id = cursor.fetchone()
+
+ if connection.server_version < 90100:
+ self.versions_to_test = ['default']
+ else:
+ self.versions_to_test = ['9.1_plus']
+
+ for version in self.versions_to_test:
+ template_file = os.path.join(os.path.dirname(__file__), "..", version, "dependents.sql")
+ template = file_as_template(template_file)
+
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % table_id)
+
+ cursor = connection.cursor()
+ cursor.execute(sql)
+ fetch_result = cursor.fetchall()
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(cursor.description):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('test_table', first_row["refname"])
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_role_dependencies.py b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_role_dependencies.py
new file mode 100644
index 00000000..d43833ec
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/tests/test_role_dependencies.py
@@ -0,0 +1,57 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+import sys
+
+from pgadmin.utils.driver import DriverRegistry
+from regression.python_test_utils.template_helper import file_as_template
+
+DriverRegistry.load_drivers()
+from pgadmin.utils.route import BaseTestGenerator
+from regression.python_test_utils import test_utils
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestRoleDependencies(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Role Dependencies SQL file', dict())
+ ]
+ def runTest(self):
+ """ When there are no Role Dependencies on the table, it returns an empty result """
+ with test_utils.Database(self.server) as (connection, database_name):
+ test_utils.create_table(self.server, database_name, "test_table")
+
+ cursor = connection.cursor()
+ cursor.execute("SELECT pg_class.oid as table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ table_id = cursor.fetchone()
+
+ self.versions_to_test = ['default']
+
+ for version in self.versions_to_test:
+ template_file = os.path.join(os.path.dirname(__file__), "..", version, "role_dependencies.sql")
+ template = file_as_template(template_file)
+
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % table_id)
+
+ cursor = connection.cursor()
+ cursor.execute(sql)
+ fetch_result = cursor.fetchall()
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(cursor.description):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('o', first_row["deptype"])
diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
index d2899875..708bfdfb 100644
--- a/web/pgadmin/browser/utils.py
+++ b/web/pgadmin/browser/utils.py
@@ -353,15 +353,15 @@ class PGChildNodeView(NodeView):
else:
where_clause = where
- query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependencies=True, where_clause=where_clause)
+ query = render_template("/".join([sql_path, 'dependencies.sql']),
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependencies = self.__fetch_dependency(conn, query)
# fetch role dependencies
if where_clause.find('subid') < 0:
- sql = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_role_dependencies=True, where_clause=where_clause)
+ sql = render_template("/".join([sql_path, 'role_dependencies.sql']),
+ where_clause=where_clause)
status, result = conn.execute_dict(sql)
if not status:
@@ -402,7 +402,7 @@ class PGChildNodeView(NodeView):
where_clause = where
query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependents=True, where_clause=where_clause)
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependents = self.__fetch_dependency(conn, query)
diff --git a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
index 223579ee..338e5f71 100644
--- a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
+++ b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
@@ -1,3 +1,12 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
import pyperclip
import time
@@ -37,7 +46,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
self.page.find_by_partial_link_text("Query Tool").click()
self.page.click_tab('Query-1')
time.sleep(5)
- ActionChains(self.page.driver).send_keys("SELECT * FROM test_table").perform()
+ ActionChains(self.page.driver).send_keys("SELECT * FROM test_table ORDER BY some_column").perform()
self.page.driver.switch_to_frame(self.page.driver.find_element_by_tag_name("iframe"))
self.page.find_by_id("btn-flash").click()
diff --git a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
index 8b018fed..17bc7bf5 100644
--- a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
+++ b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
@@ -16,10 +16,14 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest):
"""Tests to check if Debugger is vulnerable to XSS."""
scenarios = [
- ("Test table DDL generation", dict())
+ ("Tests to check if Debugger is vulnerable to XSS", dict())
]
def before(self):
+ with test_utils.Database(self.server) as (connection, _):
+ if connection.server_version < 90100:
+ self.skipTest("Functions tree node is not present in pgAdmin below PG v9.1")
+
# Some test function is needed for debugger
test_utils.create_debug_function(self.server, "postgres",
"test_function")
--
2.12.0
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
@ 2017-05-02 21:17 ` Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Sarah McAlear @ 2017-05-02 21:17 UTC (permalink / raw)
To: Joao Pedro De Almeida Pereira <[email protected]>; +Cc: Ashesh Vashi <[email protected]>; Dave Page <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Hi Hackers & Ashesh!
Is there anything else we can do for this?
Thanks!
Matt & Sarah
On Thu, Apr 27, 2017 at 10:37 AM, Joao Pedro De Almeida Pereira <
[email protected]> wrote:
> Thanks for reviewing, Ashesh.
>
> We have updated the patch. The headers are all consistent and we removed
> the __init__.py files in directories containing only .sql.
>
> Thanks!
> Joao & Matt
>
> On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
> [email protected]> wrote:
>
>> Hello Ashesh,
>>
>> Thanks for reviewing the patch.
>>
>> We added the __init__.py files into templates to convert them into
>> packages so that the tests inside of them can be found by the test runner.
>>
>> Thanks!
>> Joao & Sarah
>>
>> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
>> [email protected]> wrote:
>>
>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]> wrote:
>>>
>>>> Ashesh, can you review/commit this please?
>>>>
>>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Hackers,
>>>>>
>>>>> We found out that when you are connected to a GreenPlum database and
>>>>> try to get Dependents and Dependencies of an object the application was
>>>>> returning a SQL error.
>>>>>
>>>>> This patch splits the SQL query used to retrieve the Dependents,
>>>>> Dependencies, and Roles SQL file into multiple versioned files.
>>>>> Add Unit Tests for each file.
>>>>> Also added __init__.py files to other test directories to run the
>>>>> tests in them.
>>>>>
>>>> Hi Joao & Sarah,
>>>
>>> Why do we need to add __init__.py in the template directory?
>>> I didn't understand the purpose of the adding __init__.py files in the
>>> template directories.
>>>
>>> NOTE: The headers in those files are not consistent with the other
>>> project files.
>>>
>>> --
>>>
>>> Thanks & Regards,
>>>
>>> Ashesh Vashi
>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>> <http://www.enterprisedb.com/;
>>>
>>>
>>> *http://www.linkedin.com/in/asheshvashi*
>>> <http://www.linkedin.com/in/asheshvashi;
>>>
>>>> Add ORDER BY into Copy Selection Feature test to ensure the results are
>>>>> retrieved always in the same order
>>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and skip
>>>>> it for versions less than 9.1
>>>>>
>>>>> Thanks
>>>>>
>>>>> Joao & Sarah
>>>>>
>>>>>
>>>>> --
>>>>> Sent via pgadmin-hackers mailing list ([email protected])
>>>>> To make changes to your subscription:
>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Dave Page
>>>> Blog: http://pgsnake.blogspot.com
>>>> Twitter: @pgsnake
>>>>
>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>
>>>
>>
>
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
@ 2017-05-04 11:51 ` Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Robert Eckhardt @ 2017-05-04 11:51 UTC (permalink / raw)
To: Sarah McAlear <[email protected]>; +Cc: Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; Dave Page <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
All,
This change in the xss testing is preventing our CI from going green and is
also preventing the Dependents and Dependencies tabs in Greenplum from
being useful.
Can we either merge this or provide feedback as to what needs to change so
that it can be merged.
Thank you
Rob
On Tue, May 2, 2017 at 5:17 PM, Sarah McAlear <[email protected]> wrote:
> Hi Hackers & Ashesh!
>
> Is there anything else we can do for this?
>
> Thanks!
> Matt & Sarah
>
> On Thu, Apr 27, 2017 at 10:37 AM, Joao Pedro De Almeida Pereira <
> [email protected]> wrote:
>
>> Thanks for reviewing, Ashesh.
>>
>> We have updated the patch. The headers are all consistent and we removed
>> the __init__.py files in directories containing only .sql.
>>
>> Thanks!
>> Joao & Matt
>>
>> On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
>> [email protected]> wrote:
>>
>>> Hello Ashesh,
>>>
>>> Thanks for reviewing the patch.
>>>
>>> We added the __init__.py files into templates to convert them into
>>> packages so that the tests inside of them can be found by the test runner.
>>>
>>> Thanks!
>>> Joao & Sarah
>>>
>>> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
>>> [email protected]> wrote:
>>>
>>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]> wrote:
>>>>
>>>>> Ashesh, can you review/commit this please?
>>>>>
>>>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi Hackers,
>>>>>>
>>>>>> We found out that when you are connected to a GreenPlum database and
>>>>>> try to get Dependents and Dependencies of an object the application was
>>>>>> returning a SQL error.
>>>>>>
>>>>>> This patch splits the SQL query used to retrieve the Dependents,
>>>>>> Dependencies, and Roles SQL file into multiple versioned files.
>>>>>> Add Unit Tests for each file.
>>>>>> Also added __init__.py files to other test directories to run the
>>>>>> tests in them.
>>>>>>
>>>>> Hi Joao & Sarah,
>>>>
>>>> Why do we need to add __init__.py in the template directory?
>>>> I didn't understand the purpose of the adding __init__.py files in the
>>>> template directories.
>>>>
>>>> NOTE: The headers in those files are not consistent with the other
>>>> project files.
>>>>
>>>> --
>>>>
>>>> Thanks & Regards,
>>>>
>>>> Ashesh Vashi
>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>> <http://www.enterprisedb.com/;
>>>>
>>>>
>>>> *http://www.linkedin.com/in/asheshvashi*
>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>
>>>>> Add ORDER BY into Copy Selection Feature test to ensure the results
>>>>>> are retrieved always in the same order
>>>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and
>>>>>> skip it for versions less than 9.1
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> Joao & Sarah
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sent via pgadmin-hackers mailing list ([email protected]
>>>>>> )
>>>>>> To make changes to your subscription:
>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Dave Page
>>>>> Blog: http://pgsnake.blogspot.com
>>>>> Twitter: @pgsnake
>>>>>
>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list ([email protected])
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
@ 2017-05-05 12:18 ` Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Dave Page @ 2017-05-05 12:18 UTC (permalink / raw)
To: Robert Eckhardt <[email protected]>; +Cc: Sarah McAlear <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Can you get this polished off on Monday please Ashesh?
On Thu, May 4, 2017 at 12:51 PM, Robert Eckhardt <[email protected]>
wrote:
> All,
>
> This change in the xss testing is preventing our CI from going green and
> is also preventing the Dependents and Dependencies tabs in Greenplum from
> being useful.
>
> Can we either merge this or provide feedback as to what needs to change so
> that it can be merged.
>
> Thank you
> Rob
>
> On Tue, May 2, 2017 at 5:17 PM, Sarah McAlear <[email protected]> wrote:
>
>> Hi Hackers & Ashesh!
>>
>> Is there anything else we can do for this?
>>
>> Thanks!
>> Matt & Sarah
>>
>> On Thu, Apr 27, 2017 at 10:37 AM, Joao Pedro De Almeida Pereira <
>> [email protected]> wrote:
>>
>>> Thanks for reviewing, Ashesh.
>>>
>>> We have updated the patch. The headers are all consistent and we removed
>>> the __init__.py files in directories containing only .sql.
>>>
>>> Thanks!
>>> Joao & Matt
>>>
>>> On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
>>> [email protected]> wrote:
>>>
>>>> Hello Ashesh,
>>>>
>>>> Thanks for reviewing the patch.
>>>>
>>>> We added the __init__.py files into templates to convert them into
>>>> packages so that the tests inside of them can be found by the test runner.
>>>>
>>>> Thanks!
>>>> Joao & Sarah
>>>>
>>>> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
>>>> [email protected]> wrote:
>>>>
>>>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]> wrote:
>>>>>
>>>>>> Ashesh, can you review/commit this please?
>>>>>>
>>>>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hi Hackers,
>>>>>>>
>>>>>>> We found out that when you are connected to a GreenPlum database and
>>>>>>> try to get Dependents and Dependencies of an object the application was
>>>>>>> returning a SQL error.
>>>>>>>
>>>>>>> This patch splits the SQL query used to retrieve the Dependents,
>>>>>>> Dependencies, and Roles SQL file into multiple versioned files.
>>>>>>> Add Unit Tests for each file.
>>>>>>> Also added __init__.py files to other test directories to run the
>>>>>>> tests in them.
>>>>>>>
>>>>>> Hi Joao & Sarah,
>>>>>
>>>>> Why do we need to add __init__.py in the template directory?
>>>>> I didn't understand the purpose of the adding __init__.py files in the
>>>>> template directories.
>>>>>
>>>>> NOTE: The headers in those files are not consistent with the other
>>>>> project files.
>>>>>
>>>>> --
>>>>>
>>>>> Thanks & Regards,
>>>>>
>>>>> Ashesh Vashi
>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>> <http://www.enterprisedb.com/;
>>>>>
>>>>>
>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>>
>>>>>> Add ORDER BY into Copy Selection Feature test to ensure the results
>>>>>>> are retrieved always in the same order
>>>>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and
>>>>>>> skip it for versions less than 9.1
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Joao & Sarah
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Sent via pgadmin-hackers mailing list ([email protected]
>>>>>>> g)
>>>>>>> To make changes to your subscription:
>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Dave Page
>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>> Twitter: @pgsnake
>>>>>>
>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list ([email protected])
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
@ 2017-05-08 08:16 ` Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Dave Page @ 2017-05-08 08:16 UTC (permalink / raw)
To: Robert Eckhardt <[email protected]>; +Cc: Sarah McAlear <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>; Akshay Joshi <[email protected]>
Akshay, as Ashesh is unavailable today, can you please review/commit this
ASAP?
Thanks.
On Fri, May 5, 2017 at 1:18 PM, Dave Page <[email protected]> wrote:
> Can you get this polished off on Monday please Ashesh?
>
> On Thu, May 4, 2017 at 12:51 PM, Robert Eckhardt <[email protected]>
> wrote:
>
>> All,
>>
>> This change in the xss testing is preventing our CI from going green and
>> is also preventing the Dependents and Dependencies tabs in Greenplum from
>> being useful.
>>
>> Can we either merge this or provide feedback as to what needs to change
>> so that it can be merged.
>>
>> Thank you
>> Rob
>>
>> On Tue, May 2, 2017 at 5:17 PM, Sarah McAlear <[email protected]>
>> wrote:
>>
>>> Hi Hackers & Ashesh!
>>>
>>> Is there anything else we can do for this?
>>>
>>> Thanks!
>>> Matt & Sarah
>>>
>>> On Thu, Apr 27, 2017 at 10:37 AM, Joao Pedro De Almeida Pereira <
>>> [email protected]> wrote:
>>>
>>>> Thanks for reviewing, Ashesh.
>>>>
>>>> We have updated the patch. The headers are all consistent and we
>>>> removed the __init__.py files in directories containing only .sql.
>>>>
>>>> Thanks!
>>>> Joao & Matt
>>>>
>>>> On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
>>>> [email protected]> wrote:
>>>>
>>>>> Hello Ashesh,
>>>>>
>>>>> Thanks for reviewing the patch.
>>>>>
>>>>> We added the __init__.py files into templates to convert them into
>>>>> packages so that the tests inside of them can be found by the test runner.
>>>>>
>>>>> Thanks!
>>>>> Joao & Sarah
>>>>>
>>>>> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]> wrote:
>>>>>>
>>>>>>> Ashesh, can you review/commit this please?
>>>>>>>
>>>>>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Hi Hackers,
>>>>>>>>
>>>>>>>> We found out that when you are connected to a GreenPlum database
>>>>>>>> and try to get Dependents and Dependencies of an object the application was
>>>>>>>> returning a SQL error.
>>>>>>>>
>>>>>>>> This patch splits the SQL query used to retrieve the Dependents,
>>>>>>>> Dependencies, and Roles SQL file into multiple versioned files.
>>>>>>>> Add Unit Tests for each file.
>>>>>>>> Also added __init__.py files to other test directories to run the
>>>>>>>> tests in them.
>>>>>>>>
>>>>>>> Hi Joao & Sarah,
>>>>>>
>>>>>> Why do we need to add __init__.py in the template directory?
>>>>>> I didn't understand the purpose of the adding __init__.py files in
>>>>>> the template directories.
>>>>>>
>>>>>> NOTE: The headers in those files are not consistent with the other
>>>>>> project files.
>>>>>>
>>>>>> --
>>>>>>
>>>>>> Thanks & Regards,
>>>>>>
>>>>>> Ashesh Vashi
>>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>>> <http://www.enterprisedb.com/;
>>>>>>
>>>>>>
>>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>>>
>>>>>>> Add ORDER BY into Copy Selection Feature test to ensure the results
>>>>>>>> are retrieved always in the same order
>>>>>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and
>>>>>>>> skip it for versions less than 9.1
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> Joao & Sarah
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Sent via pgadmin-hackers mailing list (
>>>>>>>> [email protected])
>>>>>>>> To make changes to your subscription:
>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Dave Page
>>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>>> Twitter: @pgsnake
>>>>>>>
>>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Sent via pgadmin-hackers mailing list ([email protected])
>>>> To make changes to your subscription:
>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>
>>>>
>>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
@ 2017-05-08 08:50 ` Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Akshay Joshi @ 2017-05-08 08:50 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: Robert Eckhardt <[email protected]>; Sarah McAlear <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
On Mon, May 8, 2017 at 1:46 PM, Dave Page <[email protected]> wrote:
> Akshay, as Ashesh is unavailable today, can you please review/commit this
> ASAP?
>
Sure.
>
> Thanks.
>
> On Fri, May 5, 2017 at 1:18 PM, Dave Page <[email protected]> wrote:
>
>> Can you get this polished off on Monday please Ashesh?
>>
>> On Thu, May 4, 2017 at 12:51 PM, Robert Eckhardt <[email protected]>
>> wrote:
>>
>>> All,
>>>
>>> This change in the xss testing is preventing our CI from going green and
>>> is also preventing the Dependents and Dependencies tabs in Greenplum from
>>> being useful.
>>>
>>> Can we either merge this or provide feedback as to what needs to change
>>> so that it can be merged.
>>>
>>> Thank you
>>> Rob
>>>
>>> On Tue, May 2, 2017 at 5:17 PM, Sarah McAlear <[email protected]>
>>> wrote:
>>>
>>>> Hi Hackers & Ashesh!
>>>>
>>>> Is there anything else we can do for this?
>>>>
>>>> Thanks!
>>>> Matt & Sarah
>>>>
>>>> On Thu, Apr 27, 2017 at 10:37 AM, Joao Pedro De Almeida Pereira <
>>>> [email protected]> wrote:
>>>>
>>>>> Thanks for reviewing, Ashesh.
>>>>>
>>>>> We have updated the patch. The headers are all consistent and we
>>>>> removed the __init__.py files in directories containing only .sql.
>>>>>
>>>>> Thanks!
>>>>> Joao & Matt
>>>>>
>>>>> On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hello Ashesh,
>>>>>>
>>>>>> Thanks for reviewing the patch.
>>>>>>
>>>>>> We added the __init__.py files into templates to convert them into
>>>>>> packages so that the tests inside of them can be found by the test runner.
>>>>>>
>>>>>> Thanks!
>>>>>> Joao & Sarah
>>>>>>
>>>>>> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Ashesh, can you review/commit this please?
>>>>>>>>
>>>>>>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> Hi Hackers,
>>>>>>>>>
>>>>>>>>> We found out that when you are connected to a GreenPlum database
>>>>>>>>> and try to get Dependents and Dependencies of an object the application was
>>>>>>>>> returning a SQL error.
>>>>>>>>>
>>>>>>>>> This patch splits the SQL query used to retrieve the Dependents,
>>>>>>>>> Dependencies, and Roles SQL file into multiple versioned files.
>>>>>>>>> Add Unit Tests for each file.
>>>>>>>>> Also added __init__.py files to other test directories to run the
>>>>>>>>> tests in them.
>>>>>>>>>
>>>>>>>> Hi Joao & Sarah,
>>>>>>>
>>>>>>> Why do we need to add __init__.py in the template directory?
>>>>>>> I didn't understand the purpose of the adding __init__.py files in
>>>>>>> the template directories.
>>>>>>>
>>>>>>> NOTE: The headers in those files are not consistent with the other
>>>>>>> project files.
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> Thanks & Regards,
>>>>>>>
>>>>>>> Ashesh Vashi
>>>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>>>> <http://www.enterprisedb.com/;
>>>>>>>
>>>>>>>
>>>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>>>>
>>>>>>>> Add ORDER BY into Copy Selection Feature test to ensure the results
>>>>>>>>> are retrieved always in the same order
>>>>>>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and
>>>>>>>>> skip it for versions less than 9.1
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>>
>>>>>>>>> Joao & Sarah
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Sent via pgadmin-hackers mailing list (
>>>>>>>>> [email protected])
>>>>>>>>> To make changes to your subscription:
>>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Dave Page
>>>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>>>> Twitter: @pgsnake
>>>>>>>>
>>>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sent via pgadmin-hackers mailing list ([email protected])
>>>>> To make changes to your subscription:
>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>
>>>>>
>>>>
>>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
*Akshay Joshi*
*Principal Software Engineer *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
@ 2017-05-08 11:24 ` Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Akshay Joshi @ 2017-05-08 11:24 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: Robert Eckhardt <[email protected]>; Sarah McAlear <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Hi All
I have reviewed the code and have following questions:
- Why do we have empty __init__.py file in sql and templates/<module>
folder. In this patch we have couple of occurrences one of them is web/
pgadmin/browser/server_groups/servers/databases/schemas/table/templates/trigger
and web/pgadmin/browser/server_groups/servers/databases/schemas
/table/templates/trigger/sql
- Why do we have tests folder inside sql folder as we already have tests
folder in respective module. For example we have tests folder in
*web/pgadmin/browser/server_groups/servers/databases/schemas/table/column
*then
why do we need it in
*web/pgadmin/browser/server_groups/servers/databases/schemas/table/templates/column/sql/tests*
Apart from above code looks good to me.
On Mon, May 8, 2017 at 2:20 PM, Akshay Joshi <[email protected]>
wrote:
>
>
> On Mon, May 8, 2017 at 1:46 PM, Dave Page <[email protected]> wrote:
>
>> Akshay, as Ashesh is unavailable today, can you please review/commit this
>> ASAP?
>>
>
> Sure.
>
>>
>> Thanks.
>>
>> On Fri, May 5, 2017 at 1:18 PM, Dave Page <[email protected]> wrote:
>>
>>> Can you get this polished off on Monday please Ashesh?
>>>
>>> On Thu, May 4, 2017 at 12:51 PM, Robert Eckhardt <[email protected]>
>>> wrote:
>>>
>>>> All,
>>>>
>>>> This change in the xss testing is preventing our CI from going green
>>>> and is also preventing the Dependents and Dependencies tabs in Greenplum
>>>> from being useful.
>>>>
>>>> Can we either merge this or provide feedback as to what needs to change
>>>> so that it can be merged.
>>>>
>>>> Thank you
>>>> Rob
>>>>
>>>> On Tue, May 2, 2017 at 5:17 PM, Sarah McAlear <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi Hackers & Ashesh!
>>>>>
>>>>> Is there anything else we can do for this?
>>>>>
>>>>> Thanks!
>>>>> Matt & Sarah
>>>>>
>>>>> On Thu, Apr 27, 2017 at 10:37 AM, Joao Pedro De Almeida Pereira <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Thanks for reviewing, Ashesh.
>>>>>>
>>>>>> We have updated the patch. The headers are all consistent and we
>>>>>> removed the __init__.py files in directories containing only .sql.
>>>>>>
>>>>>> Thanks!
>>>>>> Joao & Matt
>>>>>>
>>>>>> On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hello Ashesh,
>>>>>>>
>>>>>>> Thanks for reviewing the patch.
>>>>>>>
>>>>>>> We added the __init__.py files into templates to convert them into
>>>>>>> packages so that the tests inside of them can be found by the test runner.
>>>>>>>
>>>>>>> Thanks!
>>>>>>> Joao & Sarah
>>>>>>>
>>>>>>> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Ashesh, can you review/commit this please?
>>>>>>>>>
>>>>>>>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Hackers,
>>>>>>>>>>
>>>>>>>>>> We found out that when you are connected to a GreenPlum database
>>>>>>>>>> and try to get Dependents and Dependencies of an object the application was
>>>>>>>>>> returning a SQL error.
>>>>>>>>>>
>>>>>>>>>> This patch splits the SQL query used to retrieve the Dependents,
>>>>>>>>>> Dependencies, and Roles SQL file into multiple versioned files.
>>>>>>>>>> Add Unit Tests for each file.
>>>>>>>>>> Also added __init__.py files to other test directories to run the
>>>>>>>>>> tests in them.
>>>>>>>>>>
>>>>>>>>> Hi Joao & Sarah,
>>>>>>>>
>>>>>>>> Why do we need to add __init__.py in the template directory?
>>>>>>>> I didn't understand the purpose of the adding __init__.py files in
>>>>>>>> the template directories.
>>>>>>>>
>>>>>>>> NOTE: The headers in those files are not consistent with the other
>>>>>>>> project files.
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> Thanks & Regards,
>>>>>>>>
>>>>>>>> Ashesh Vashi
>>>>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>>>>> <http://www.enterprisedb.com/;
>>>>>>>>
>>>>>>>>
>>>>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>>>>>
>>>>>>>>> Add ORDER BY into Copy Selection Feature test to ensure the
>>>>>>>>>> results are retrieved always in the same order
>>>>>>>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test and
>>>>>>>>>> skip it for versions less than 9.1
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Joao & Sarah
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Sent via pgadmin-hackers mailing list (
>>>>>>>>>> [email protected])
>>>>>>>>>> To make changes to your subscription:
>>>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Dave Page
>>>>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>>>>> Twitter: @pgsnake
>>>>>>>>>
>>>>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sent via pgadmin-hackers mailing list ([email protected]
>>>>>> )
>>>>>> To make changes to your subscription:
>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>
--
*Akshay Joshi*
*Principal Software Engineer *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
@ 2017-05-08 11:28 ` Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Dave Page @ 2017-05-08 11:28 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: Robert Eckhardt <[email protected]>; Sarah McAlear <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Hi
On Mon, May 8, 2017 at 12:24 PM, Akshay Joshi <[email protected]
> wrote:
> Hi All
>
> I have reviewed the code and have following questions:
>
> - Why do we have empty __init__.py file in sql and templates/<module>
> folder. In this patch we have couple of occurrences one of them is web/
> pgadmin/browser/server_groups/servers/databases/schemas/table/templates/trigger
> and web/pgadmin/browser/server_groups/servers/databases/schemas/table/
> templates/trigger/sql
>
> That was already answered up-thread: We added the __init__.py files into
templates to convert them into packages so that the tests inside of them
can be found by the test runner.
>
> - Why do we have tests folder inside sql folder as we already have
> tests folder in respective module. For example we have tests folder in
> *web/pgadmin/browser/server_groups/servers/databases/schemas/table/column *then
> why do we need it in
> *web/pgadmin/browser/server_groups/servers/databases/schemas/table/templates/column/sql/tests*
>
> That does seem like a valid concern to me.
> Apart from above code looks good to me.
>
> On Mon, May 8, 2017 at 2:20 PM, Akshay Joshi <
> [email protected]> wrote:
>
>>
>>
>> On Mon, May 8, 2017 at 1:46 PM, Dave Page <[email protected]> wrote:
>>
>>> Akshay, as Ashesh is unavailable today, can you please review/commit
>>> this ASAP?
>>>
>>
>> Sure.
>>
>>>
>>> Thanks.
>>>
>>> On Fri, May 5, 2017 at 1:18 PM, Dave Page <[email protected]> wrote:
>>>
>>>> Can you get this polished off on Monday please Ashesh?
>>>>
>>>> On Thu, May 4, 2017 at 12:51 PM, Robert Eckhardt <[email protected]>
>>>> wrote:
>>>>
>>>>> All,
>>>>>
>>>>> This change in the xss testing is preventing our CI from going green
>>>>> and is also preventing the Dependents and Dependencies tabs in Greenplum
>>>>> from being useful.
>>>>>
>>>>> Can we either merge this or provide feedback as to what needs to
>>>>> change so that it can be merged.
>>>>>
>>>>> Thank you
>>>>> Rob
>>>>>
>>>>> On Tue, May 2, 2017 at 5:17 PM, Sarah McAlear <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hi Hackers & Ashesh!
>>>>>>
>>>>>> Is there anything else we can do for this?
>>>>>>
>>>>>> Thanks!
>>>>>> Matt & Sarah
>>>>>>
>>>>>> On Thu, Apr 27, 2017 at 10:37 AM, Joao Pedro De Almeida Pereira <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Thanks for reviewing, Ashesh.
>>>>>>>
>>>>>>> We have updated the patch. The headers are all consistent and we
>>>>>>> removed the __init__.py files in directories containing only .sql.
>>>>>>>
>>>>>>> Thanks!
>>>>>>> Joao & Matt
>>>>>>>
>>>>>>> On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Hello Ashesh,
>>>>>>>>
>>>>>>>> Thanks for reviewing the patch.
>>>>>>>>
>>>>>>>> We added the __init__.py files into templates to convert them into
>>>>>>>> packages so that the tests inside of them can be found by the test runner.
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>> Joao & Sarah
>>>>>>>>
>>>>>>>> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Ashesh, can you review/commit this please?
>>>>>>>>>>
>>>>>>>>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Hackers,
>>>>>>>>>>>
>>>>>>>>>>> We found out that when you are connected to a GreenPlum database
>>>>>>>>>>> and try to get Dependents and Dependencies of an object the application was
>>>>>>>>>>> returning a SQL error.
>>>>>>>>>>>
>>>>>>>>>>> This patch splits the SQL query used to retrieve the Dependents,
>>>>>>>>>>> Dependencies, and Roles SQL file into multiple versioned files.
>>>>>>>>>>> Add Unit Tests for each file.
>>>>>>>>>>> Also added __init__.py files to other test directories to run
>>>>>>>>>>> the tests in them.
>>>>>>>>>>>
>>>>>>>>>> Hi Joao & Sarah,
>>>>>>>>>
>>>>>>>>> Why do we need to add __init__.py in the template directory?
>>>>>>>>> I didn't understand the purpose of the adding __init__.py files in
>>>>>>>>> the template directories.
>>>>>>>>>
>>>>>>>>> NOTE: The headers in those files are not consistent with the other
>>>>>>>>> project files.
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> Thanks & Regards,
>>>>>>>>>
>>>>>>>>> Ashesh Vashi
>>>>>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>>>>>> <http://www.enterprisedb.com/;
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>>>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>>>>>>
>>>>>>>>>> Add ORDER BY into Copy Selection Feature test to ensure the
>>>>>>>>>>> results are retrieved always in the same order
>>>>>>>>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test
>>>>>>>>>>> and skip it for versions less than 9.1
>>>>>>>>>>>
>>>>>>>>>>> Thanks
>>>>>>>>>>>
>>>>>>>>>>> Joao & Sarah
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Sent via pgadmin-hackers mailing list (
>>>>>>>>>>> [email protected])
>>>>>>>>>>> To make changes to your subscription:
>>>>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Dave Page
>>>>>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>>>>>> Twitter: @pgsnake
>>>>>>>>>>
>>>>>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Sent via pgadmin-hackers mailing list ([email protected]
>>>>>>> g)
>>>>>>> To make changes to your subscription:
>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Dave Page
>>>> Blog: http://pgsnake.blogspot.com
>>>> Twitter: @pgsnake
>>>>
>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>
>>>
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>>
>> --
>> *Akshay Joshi*
>> *Principal Software Engineer *
>>
>>
>>
>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91 976-788-8246
>> <+91%2097678%2088246>*
>>
>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91 976-788-8246
> <+91%2097678%2088246>*
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
@ 2017-05-08 16:14 ` Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Sarah McAlear @ 2017-05-08 16:14 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: Akshay Joshi <[email protected]>; Robert Eckhardt <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Hi!
This patch has the tests moved to the test directories of the parent.
Thanks,
Joao & Sarah
On Mon, May 8, 2017 at 7:28 AM, Dave Page <[email protected]> wrote:
> Hi
>
> On Mon, May 8, 2017 at 12:24 PM, Akshay Joshi <
> [email protected]> wrote:
>
>> Hi All
>>
>> I have reviewed the code and have following questions:
>>
>> - Why do we have empty __init__.py file in sql and templates/<module>
>> folder. In this patch we have couple of occurrences one of them is web/
>> pgadmin/browser/server_groups/servers/databases/schemas/table/templates/trigger
>> and web/pgadmin/browser/server_groups/servers/databases/schemas
>> /table/templates/trigger/sql
>>
>> That was already answered up-thread: We added the __init__.py files into
> templates to convert them into packages so that the tests inside of them
> can be found by the test runner.
>
>>
>> - Why do we have tests folder inside sql folder as we already have
>> tests folder in respective module. For example we have tests folder in
>> *web/pgadmin/browser/server_groups/servers/databases/schemas/table/column *then
>> why do we need it in
>> *web/pgadmin/browser/server_groups/servers/databases/schemas/table/templates/column/sql/tests*
>>
>> That does seem like a valid concern to me.
>
>
>> Apart from above code looks good to me.
>>
>> On Mon, May 8, 2017 at 2:20 PM, Akshay Joshi <
>> [email protected]> wrote:
>>
>>>
>>>
>>> On Mon, May 8, 2017 at 1:46 PM, Dave Page <[email protected]> wrote:
>>>
>>>> Akshay, as Ashesh is unavailable today, can you please review/commit
>>>> this ASAP?
>>>>
>>>
>>> Sure.
>>>
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, May 5, 2017 at 1:18 PM, Dave Page <[email protected]> wrote:
>>>>
>>>>> Can you get this polished off on Monday please Ashesh?
>>>>>
>>>>> On Thu, May 4, 2017 at 12:51 PM, Robert Eckhardt <[email protected]
>>>>> > wrote:
>>>>>
>>>>>> All,
>>>>>>
>>>>>> This change in the xss testing is preventing our CI from going green
>>>>>> and is also preventing the Dependents and Dependencies tabs in Greenplum
>>>>>> from being useful.
>>>>>>
>>>>>> Can we either merge this or provide feedback as to what needs to
>>>>>> change so that it can be merged.
>>>>>>
>>>>>> Thank you
>>>>>> Rob
>>>>>>
>>>>>> On Tue, May 2, 2017 at 5:17 PM, Sarah McAlear <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Hackers & Ashesh!
>>>>>>>
>>>>>>> Is there anything else we can do for this?
>>>>>>>
>>>>>>> Thanks!
>>>>>>> Matt & Sarah
>>>>>>>
>>>>>>> On Thu, Apr 27, 2017 at 10:37 AM, Joao Pedro De Almeida Pereira <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Thanks for reviewing, Ashesh.
>>>>>>>>
>>>>>>>> We have updated the patch. The headers are all consistent and we
>>>>>>>> removed the __init__.py files in directories containing only .sql.
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>> Joao & Matt
>>>>>>>>
>>>>>>>> On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> Hello Ashesh,
>>>>>>>>>
>>>>>>>>> Thanks for reviewing the patch.
>>>>>>>>>
>>>>>>>>> We added the __init__.py files into templates to convert them into
>>>>>>>>> packages so that the tests inside of them can be found by the test runner.
>>>>>>>>>
>>>>>>>>> Thanks!
>>>>>>>>> Joao & Sarah
>>>>>>>>>
>>>>>>>>> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> Ashesh, can you review/commit this please?
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira <
>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi Hackers,
>>>>>>>>>>>>
>>>>>>>>>>>> We found out that when you are connected to a GreenPlum
>>>>>>>>>>>> database and try to get Dependents and Dependencies of an object the
>>>>>>>>>>>> application was returning a SQL error.
>>>>>>>>>>>>
>>>>>>>>>>>> This patch splits the SQL query used to retrieve the
>>>>>>>>>>>> Dependents, Dependencies, and Roles SQL file into multiple versioned files.
>>>>>>>>>>>> Add Unit Tests for each file.
>>>>>>>>>>>> Also added __init__.py files to other test directories to run
>>>>>>>>>>>> the tests in them.
>>>>>>>>>>>>
>>>>>>>>>>> Hi Joao & Sarah,
>>>>>>>>>>
>>>>>>>>>> Why do we need to add __init__.py in the template directory?
>>>>>>>>>> I didn't understand the purpose of the adding __init__.py files
>>>>>>>>>> in the template directories.
>>>>>>>>>>
>>>>>>>>>> NOTE: The headers in those files are not consistent with the
>>>>>>>>>> other project files.
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> Thanks & Regards,
>>>>>>>>>>
>>>>>>>>>> Ashesh Vashi
>>>>>>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>>>>>>> <http://www.enterprisedb.com/;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>>>>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>>>>>>>
>>>>>>>>>>> Add ORDER BY into Copy Selection Feature test to ensure the
>>>>>>>>>>>> results are retrieved always in the same order
>>>>>>>>>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test
>>>>>>>>>>>> and skip it for versions less than 9.1
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks
>>>>>>>>>>>>
>>>>>>>>>>>> Joao & Sarah
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Sent via pgadmin-hackers mailing list (
>>>>>>>>>>>> [email protected])
>>>>>>>>>>>> To make changes to your subscription:
>>>>>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Dave Page
>>>>>>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>>>>>>> Twitter: @pgsnake
>>>>>>>>>>>
>>>>>>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Sent via pgadmin-hackers mailing list (
>>>>>>>> [email protected])
>>>>>>>> To make changes to your subscription:
>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Dave Page
>>>>> Blog: http://pgsnake.blogspot.com
>>>>> Twitter: @pgsnake
>>>>>
>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Dave Page
>>>> Blog: http://pgsnake.blogspot.com
>>>> Twitter: @pgsnake
>>>>
>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>
>>>
>>>
>>> --
>>> *Akshay Joshi*
>>> *Principal Software Engineer *
>>>
>>>
>>>
>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>> 976-788-8246 <+91%2097678%2088246>*
>>>
>>
>>
>>
>> --
>> *Akshay Joshi*
>> *Principal Software Engineer *
>>
>>
>>
>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91 976-788-8246
>> <+91%2097678%2088246>*
>>
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] 0001-Fix-error-while-checking-Dependents-and-Dependencies.patch (71.2K, 3-0001-Fix-error-while-checking-Dependents-and-Dependencies.patch)
download | inline diff:
From 58d79acf8b934414e03eeb6c84918ab165caaac0 Mon Sep 17 00:00:00 2001
From: Pivotal <[email protected]>
Date: Mon, 8 May 2017 12:12:24 -0400
Subject: [PATCH] Fix error while checking Dependents and Dependencies of
object in GreenPlum: - Make SQL template UT visible to runtest - Add SQL
to retrieve dependencies for GreenPlum - Extract Role Dependencies from
single dependents file - Split template for dependents SQL - Add 'SET
LOCAL join_collapse_limit=8;' to dependency/dependents to make them faster.
Only caveat is that this will remain unchanged for the session - Add more
expectations to role dependencies - Specify order of query in
copy_selected_query_results_feature_test to make tests pass - GreenPlum and
Postgres order these results differently by default without an order clause
specified. - Skip XSS test for GreenPlum - Moved tests to the correct
folders
---
.../databases/schemas/tables/templates/__init__.py | 0
.../schemas/tables/templates/column/__init__.py | 0
.../templates/column/sql/9.2_plus/__init__.py | 0
.../templates/column/sql/default/__init__.py | 0
.../templates/column/sql/tests/test_column_acl.py | 47 -------------
.../column/sql/tests/test_column_properties.py | 56 ----------------
.../schemas/tables/templates/table/__init__.py | 0
.../schemas/tables/templates/table/sql/__init__.py | 0
.../tables/templates/table/sql/tests/__init__.py | 0
.../templates/table/sql/tests/test_tables_acl.py | 66 -------------------
.../templates/table/sql/tests/test_tables_node.py | 74 ---------------------
.../table/sql/tests/test_tables_properties.py | 77 ----------------------
.../templates/trigger/sql/9.1_plus/__init__.py | 0
.../tables/templates/trigger/sql/__init__.py | 0
.../templates/trigger/sql/default/__init__.py | 0
.../tables/templates/trigger/sql/tests/__init__.py | 0
.../trigger/sql/tests/test_trigger_get_oid.py | 60 -----------------
.../tables/tests/test_column_acl_sql_template.py | 51 ++++++++++++++
.../tests/test_column_properties_sql_template.py | 52 +++++++++++++++
.../tables/tests/test_tables_acl_sql_template.py | 54 +++++++++++++++
.../tables/tests/test_tables_node_sql_template.py | 51 ++++++++++++++
.../tests/test_tables_properties_sql_template.py | 67 +++++++++++++++++++
.../tests/test_trigger_get_oid_sql_template.py | 53 +++++++++++++++
.../tests/test_trigger_nodes_sql_template.py | 43 ++++++++++++
.../depends/sql/9.1_plus/dependencies.sql | 45 +++++++++++++
.../templates/depends/sql/9.1_plus/dependents.sql | 44 +++++++++++++
.../templates/depends/sql/default/dependencies.sql | 42 ++++++++++++
.../templates/depends/sql/default/dependents.sql | 66 +------------------
.../depends/sql/default/role_dependencies.sql | 4 ++
.../tests/test_dependencies_sql_template.py | 51 ++++++++++++++
.../servers/tests/test_dependents_sql_template.py | 52 +++++++++++++++
.../tests/test_role_dependencies_sql_template.py | 52 +++++++++++++++
web/pgadmin/browser/utils.py | 10 +--
.../copy_selected_query_results_feature_test.py | 11 +++-
.../xss_checks_pgadmin_debugger_test.py | 6 +-
.../python_test_utils/sql_template_test_base.py} | 50 ++++++++------
36 files changed, 715 insertions(+), 469 deletions(-)
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql_template.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql_template.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql_template.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql_template.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql_template.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql_template.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql_template.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql_template.py
create mode 100644 web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql_template.py
create mode 100644 web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql_template.py
rename web/{pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py => regression/python_test_utils/sql_template_test_base.py} (61%)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
deleted file mode 100644
index 7be945c7..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestColumnAcl(BaseTestGenerator):
- def runTest(self):
- """ When there are no permissions on the column, it returns an empty result """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT pg_class.oid as table_id, "
- "pg_attribute.attnum as column_id "
- "FROM pg_class join pg_attribute on attrelid=pg_class.oid "
- "where pg_class.relname='test_table'"
- " and pg_attribute.attname = 'some_column'")
- table_id, column_id = cursor.fetchone()
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "acl.sql")
- template = file_as_template(template_file)
-
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- tid=table_id,
- clid=column_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- self.assertEqual(0, len(fetch_result))
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
deleted file mode 100644
index b1984bda..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
+++ /dev/null
@@ -1,56 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestColumnProperties(BaseTestGenerator):
- def runTest(self):
- """ This tests that column properties are returned"""
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
- table_id = cursor.fetchone()[0]
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "properties.sql")
- template = file_as_template(template_file)
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- tid=table_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- first_row = {}
- for index, description in enumerate(cursor.description):
- first_row[description.name] = fetch_result[0][index]
-
- self.assertEqual('some_column', first_row['name'])
- self.assertEqual('character varying', first_row['cltype'])
- self.assertEqual(2, len(fetch_result))
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py
deleted file mode 100644
index a0f7f94e..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py
+++ /dev/null
@@ -1,66 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTablesAcl(BaseTestGenerator):
- scenarios = [
- ("Test query returns the permissions when there are permissions set up"
- " on the table", dict())
- ]
-
- def runTest(self):
- """ This tests that when there are permissions set up on the table, acl query returns the permissions"""
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("GRANT SELECT ON test_table TO PUBLIC")
-
- cursor = connection.cursor()
- cursor.execute("SELECT oid FROM pg_class WHERE relname='test_table'")
- table_id = cursor.fetchone()[0]
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "acl.sql")
- template = file_as_template(template_file)
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- tid=table_id)
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- public_acls = list(filter(lambda acl: acl[1] == 'PUBLIC', fetch_result))
- self.assertEqual(len(public_acls), 1)
-
- new_acl_map = dict(zip(map(lambda column: column.name, cursor.description), public_acls[0]))
-
- self.assertEqual('PUBLIC', new_acl_map['grantee'])
- self.assertEqual(self.server['username'], new_acl_map['grantor'])
- self.assertEqual('relacl', new_acl_map['deftype'])
- self.assertEqual(['r'], new_acl_map['privileges'])
- self.assertEqual([False], new_acl_map['grantable'])
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py
deleted file mode 100644
index 21ec3275..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py
+++ /dev/null
@@ -1,74 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from jinja2 import BaseLoader
-from jinja2 import Environment
-
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTablesNode(BaseTestGenerator):
- scenarios = [
- ("This scenario tests that all applicable sql template versions can "
- "fetch table names", dict())
- ]
-
- def runTest(self):
- """ This tests that all applicable sql template versions can fetch table names """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- if connection.server_version < 91000:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['default', '9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "nodes.sql")
- file_content = open(template_file, 'r').read()
-
- env = Environment(loader=SimpleTemplateLoader(file_content))
-
- template = env.get_template("")
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id)
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
-
- first_row = {}
- for index, description in enumerate(cursor.description):
- first_row[description.name] = fetch_result[0][index]
-
- oid = first_row['oid']
- name = first_row['name']
- triggercount = first_row['triggercount']
- has_enable_triggers = first_row['has_enable_triggers']
-
- self.assertIsNotNone(long(oid))
- self.assertEqual('test_table', name)
- # triggercount is sometimes returned as a string for some reason
- self.assertEqual(0, long(triggercount))
- self.assertIsNotNone(long(has_enable_triggers))
-
-
-class SimpleTemplateLoader(BaseLoader):
- def __init__(self, file_content):
- self.file_content = file_content
-
- def get_source(self, *args):
- return self.file_content, "required-return-not-a-real-file.txt", True
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py
deleted file mode 100644
index 5984bda5..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py
+++ /dev/null
@@ -1,77 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTablesProperties(BaseTestGenerator):
- scenarios = [
- ("This scenario tests that all applicable sql template versions can "
- "fetch some ddl", dict())
- ]
-
- def runTest(self):
- """ This tests that all applicable sql template versions can fetch some ddl """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute(u"""
- SELECT
- db.oid as did, datlastsysoid
- FROM
- pg_database db
- WHERE db.datname = '{0}'""".format(database_name)
- )
- database_id, last_system_oid = cursor.fetchone()
-
- cursor = connection.cursor()
- cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
- table_id = cursor.fetchone()[0]
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "properties.sql")
- template = file_as_template(template_file)
-
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- did=database_id,
- datlastsysoid=last_system_oid,
- tid=table_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchone()
-
- first_row = {}
- for index, description in enumerate(cursor.description):
- first_row[description.name] = fetch_result[index]
-
- self.assertEqual('test_table', first_row['name'])
- # triggercount is sometimes returned as a string for some reason
- self.assertEqual(0, long(first_row['triggercount']))
- self.assertEqual(None, first_row['typname'])
- self.assertEqual([], first_row['coll_inherits'])
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
deleted file mode 100644
index f2b637ee..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
+++ /dev/null
@@ -1,60 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-import jinja2
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTriggerGetOid(BaseTestGenerator):
- def runTest(self):
- """ When there are no permissions on the column, it returns an empty result """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT pg_class.oid as table_id, "
- "pg_attribute.attnum as column_id "
- "FROM pg_class join pg_attribute on attrelid=pg_class.oid "
- "where pg_class.relname='test_table'"
- " and pg_attribute.attname = 'some_column'")
- table_id, column_id = cursor.fetchone()
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "get_oid.sql")
-
- jinja2.filters.FILTERS['qtLiteral'] = lambda value: "NULL"
- template = file_as_template(template_file)
-
- sql = template.render(data={'name': None},
- tid=table_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- self.assertEqual(0, len(fetch_result))
-
-
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql_template.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql_template.py
new file mode 100644
index 00000000..bc421a33
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql_template.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestColumnAclSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column ACL SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestColumnAclSqlTemplate, self).__init__()
+ self.table_id = -1
+ self.column_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id, "
+ "pg_attribute.attnum AS column_id "
+ "FROM pg_class JOIN pg_attribute ON attrelid=pg_class.oid "
+ "WHERE pg_class.relname='test_table'"
+ " AND pg_attribute.attname = 'some_column'")
+ self.table_id, self.column_id = cursor.fetchone()
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "acl.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ tid=self.table_id,
+ clid=self.column_id
+ )
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(0, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "column", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql_template.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql_template.py
new file mode 100644
index 00000000..098ed5b8
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql_template.py
@@ -0,0 +1,52 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestColumnPropertiesSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column Properties SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestColumnPropertiesSqlTemplate, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
+
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "properties.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ tid=self.table_id
+ )
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('some_column', first_row['name'])
+ self.assertEqual('character varying', first_row['cltype'])
+ self.assertEqual(2, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "column", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql_template.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql_template.py
new file mode 100644
index 00000000..d1ed3d7e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql_template.py
@@ -0,0 +1,54 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+from regression.python_test_utils.template_helper import file_as_template
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+
+
+class TestTablesAclSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ ("Test query returns the permissions when there are permissions set up"
+ " on the table", dict())
+ ]
+
+ def __init__(self):
+ super(TestTablesAclSqlTemplate, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("GRANT SELECT ON test_table TO PUBLIC")
+ cursor = connection.cursor()
+ cursor.execute("SELECT oid FROM pg_class WHERE relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "acl.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ tid=self.table_id)
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ public_acls = list(filter(lambda acl: acl[1] == 'PUBLIC', fetch_result))
+ self.assertEqual(len(public_acls), 1)
+
+ new_acl_map = dict(zip(map(lambda column: column.name, descriptions), public_acls[0]))
+
+ self.assertEqual('PUBLIC', new_acl_map['grantee'])
+ self.assertEqual(self.server['username'], new_acl_map['grantor'])
+ self.assertEqual('relacl', new_acl_map['deftype'])
+ self.assertEqual(['r'], new_acl_map['privileges'])
+ self.assertEqual([False], new_acl_map['grantable'])
+ return public_acls
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "table", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql_template.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql_template.py
new file mode 100644
index 00000000..9355a8bb
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql_template.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestTablesNodeSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ ("This scenario tests that all applicable sql template versions can "
+ "fetch table names", dict())
+ ]
+
+ def test_setup(self, connection, cursor):
+ pass
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "nodes.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id)
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ oid = first_row['oid']
+ name = first_row['name']
+ triggercount = first_row['triggercount']
+ has_enable_triggers = first_row['has_enable_triggers']
+
+ self.assertIsNotNone(long(oid))
+ self.assertEqual('test_table', name)
+ # triggercount is sometimes returned as a string for some reason
+ self.assertEqual(0, long(triggercount))
+ self.assertIsNotNone(long(has_enable_triggers))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "table", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql_template.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql_template.py
new file mode 100644
index 00000000..546f20dd
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql_template.py
@@ -0,0 +1,67 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.template_helper import file_as_template
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+
+
+class TestTablesPropertiesSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ ("This scenario tests that all applicable sql template versions can "
+ "fetch some ddl", dict())
+ ]
+
+ def __init__(self):
+ super(TestTablesPropertiesSqlTemplate, self).__init__()
+ self.database_id = -1
+ self.last_system_oid = -1
+ self.table_id = -1
+
+ def assertions(self, fetch_result, descriptions):
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('test_table', first_row['name'])
+ # triggercount is sometimes returned as a string for some reason
+ self.assertEqual(0, long(first_row['triggercount']))
+ self.assertEqual(None, first_row['typname'])
+ self.assertEqual([], first_row['coll_inherits'])
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "properties.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ did=self.database_id,
+ datlastsysoid=self.last_system_oid,
+ tid=self.table_id
+ )
+ return sql
+
+ def test_setup(self, connection, cursor):
+ cursor.execute(u"""
+ SELECT
+ db.oid as did, datlastsysoid
+ FROM
+ pg_database db
+ WHERE db.datname = '{0}'""".format(self.database_name)
+ )
+ self.database_id, self.last_system_oid = cursor.fetchone()
+
+ cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "table", "sql", version, filename)
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql_template.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql_template.py
new file mode 100644
index 00000000..267a6141
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql_template.py
@@ -0,0 +1,53 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+import jinja2
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+
+class TestTriggerGetOidSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ ('Test Trigger to retrieve OID SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestTriggerGetOidSqlTemplate, self).__init__()
+ self.table_id = -1
+ self.column_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id, "
+ "pg_attribute.attnum AS column_id "
+ "FROM pg_class JOIN pg_attribute ON attrelid=pg_class.oid "
+ "WHERE pg_class.relname='test_table'"
+ " AND pg_attribute.attname = 'some_column'")
+ self.table_id, self.column_id = cursor.fetchone()
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "get_oid.sql")
+ jinja2.filters.FILTERS['qtLiteral'] = lambda value: "NULL"
+ template = file_as_template(template_file)
+
+ sql = template.render(data={'name': None},
+ tid=self.table_id
+ )
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(0, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "trigger", "sql", version, filename)
+
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql_template.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql_template.py
new file mode 100644
index 00000000..f1def651
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql_template.py
@@ -0,0 +1,43 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestTriggerNodesSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ ('Test Trigger Nodes SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestTriggerNodesSqlTemplate, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "nodes.sql")
+ template = file_as_template(template_file)
+ sql = template.render(tid=self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(0, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "trigger", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
new file mode 100644
index 00000000..e5bb8cb6
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
@@ -0,0 +1,45 @@
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
new file mode 100644
index 00000000..1281672f
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
@@ -0,0 +1,44 @@
+SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL THEN 'y'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.objid=cl.oid
+LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.objid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.objid=tg.oid
+LEFT JOIN pg_type ty ON dep.objid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.objid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.objid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.objid=la.oid
+LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
+{{where_clause}} AND
+classid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY classid, cl.relkind
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
new file mode 100644
index 00000000..aae5982e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
@@ -0,0 +1,42 @@
+SET LOCAL join_collapse_limit=8;
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
index e2ba3d6b..2fe2ef3e 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
@@ -1,59 +1,4 @@
-{% if fetch_dependencies %}
-SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
- CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
- WHEN tg.oid IS NOT NULL THEN 'T'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
- WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
- WHEN la.oid IS NOT NULL THEN 'l'::text
- WHEN rw.oid IS NOT NULL THEN 'R'::text
- WHEN co.oid IS NOT NULL THEN 'C'::text || contype
- WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
- ELSE ''
- END AS type,
- COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
- END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
-FROM pg_depend dep
-LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
-LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
-LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
-LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
-LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
-LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
-LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
-LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
-LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
-LEFT JOIN pg_class coc ON co.conrelid=coc.oid
-LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
-LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
-LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
-LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
-LEFT JOIN pg_language la ON dep.refobjid=la.oid
-LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
-LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
-{{where_clause}} AND
-refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
- ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
- 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY refclassid, cl.relkind
-{% endif %}
-
-{% if fetch_role_dependencies %}
-SELECT rolname AS refname, refclassid, deptype
-FROM pg_shdepend dep
-LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
-{{where_clause}} ORDER BY 1
-{% endif %}
-
-{% if fetch_dependents %}
+SET LOCAL join_collapse_limit=8;
SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
WHEN tg.oid IS NOT NULL THEN 'T'::text
@@ -64,13 +9,11 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
END AS refname,
COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
FROM pg_depend dep
@@ -91,11 +34,8 @@ LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
LEFT JOIN pg_language la ON dep.objid=la.oid
LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
{{where_clause}} AND
classid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY classid, cl.relkind
-{% endif %}
+ORDER BY classid, cl.relkind;
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
new file mode 100644
index 00000000..25fc3f85
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
@@ -0,0 +1,4 @@
+SELECT rolname AS refname, refclassid, deptype
+FROM pg_shdepend dep
+LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
+{{where_clause}} ORDER BY 1
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql_template.py b/web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql_template.py
new file mode 100644
index 00000000..f7d2fe64
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql_template.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestDependenciesSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestDependenciesSqlTemplate, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "dependencies.sql")
+ template = file_as_template(template_file)
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('public', first_row["refname"])
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "depends", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql_template.py b/web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql_template.py
new file mode 100644
index 00000000..0068cd45
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql_template.py
@@ -0,0 +1,52 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+
+class TestDependentsSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestDependentsSqlTemplate, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "dependents.sql")
+ template = file_as_template(template_file)
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('test_table', first_row["refname"])
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "depends", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql_template.py b/web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql_template.py
new file mode 100644
index 00000000..a1bedc4c
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql_template.py
@@ -0,0 +1,52 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+
+class TestRoleDependenciesSqlTemplate(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Role Dependencies SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestRoleDependenciesSqlTemplate, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+ self.versions_to_test = ['default']
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "role_dependencies.sql")
+ template = file_as_template(template_file)
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('o', first_row["deptype"])
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "depends", "sql", version, filename)
diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
index d2899875..708bfdfb 100644
--- a/web/pgadmin/browser/utils.py
+++ b/web/pgadmin/browser/utils.py
@@ -353,15 +353,15 @@ class PGChildNodeView(NodeView):
else:
where_clause = where
- query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependencies=True, where_clause=where_clause)
+ query = render_template("/".join([sql_path, 'dependencies.sql']),
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependencies = self.__fetch_dependency(conn, query)
# fetch role dependencies
if where_clause.find('subid') < 0:
- sql = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_role_dependencies=True, where_clause=where_clause)
+ sql = render_template("/".join([sql_path, 'role_dependencies.sql']),
+ where_clause=where_clause)
status, result = conn.execute_dict(sql)
if not status:
@@ -402,7 +402,7 @@ class PGChildNodeView(NodeView):
where_clause = where
query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependents=True, where_clause=where_clause)
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependents = self.__fetch_dependency(conn, query)
diff --git a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
index 223579ee..338e5f71 100644
--- a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
+++ b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
@@ -1,3 +1,12 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
import pyperclip
import time
@@ -37,7 +46,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
self.page.find_by_partial_link_text("Query Tool").click()
self.page.click_tab('Query-1')
time.sleep(5)
- ActionChains(self.page.driver).send_keys("SELECT * FROM test_table").perform()
+ ActionChains(self.page.driver).send_keys("SELECT * FROM test_table ORDER BY some_column").perform()
self.page.driver.switch_to_frame(self.page.driver.find_element_by_tag_name("iframe"))
self.page.find_by_id("btn-flash").click()
diff --git a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
index 8b018fed..17bc7bf5 100644
--- a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
+++ b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
@@ -16,10 +16,14 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest):
"""Tests to check if Debugger is vulnerable to XSS."""
scenarios = [
- ("Test table DDL generation", dict())
+ ("Tests to check if Debugger is vulnerable to XSS", dict())
]
def before(self):
+ with test_utils.Database(self.server) as (connection, _):
+ if connection.server_version < 90100:
+ self.skipTest("Functions tree node is not present in pgAdmin below PG v9.1")
+
# Some test function is needed for debugger
test_utils.create_debug_function(self.server, "postgres",
"test_function")
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py b/web/regression/python_test_utils/sql_template_test_base.py
similarity index 61%
rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
rename to web/regression/python_test_utils/sql_template_test_base.py
index b23bf60a..bf0f6820 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
+++ b/web/regression/python_test_utils/sql_template_test_base.py
@@ -7,45 +7,57 @@
#
##########################################################################
-import os
import sys
-
+from pgadmin.utils.route import BaseTestGenerator
+from regression.python_test_utils import test_utils
from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
if sys.version_info[0] >= 3:
long = int
-class TestTriggerNodes(BaseTestGenerator):
+class SQLTemplateTestBase(BaseTestGenerator):
+ scenarios = [
+ ("parent test class", dict(ignore_test=True))
+ ]
+
+ def __init__(self):
+ super(SQLTemplateTestBase, self).__init__()
+ self.database_name = -1
+ self.versions_to_test = -1
+
+ def test_setup(self, connection, cursor):
+ pass
+
+ def generate_sql(self, version):
+ pass
+
+ def assertions(self, fetch_result, descriptions):
+ pass
+
def runTest(self):
- """ When there are no triggers, it returns an empty result """
+ if hasattr(self, "ignore_test"):
+ return
+
with test_utils.Database(self.server) as (connection, database_name):
test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT pg_class.oid AS table_id "
- "FROM pg_class "
- "WHERE pg_class.relname='test_table'")
- table_id = cursor.fetchone()[0]
+ self.database_name = database_name
if connection.server_version < 90100:
self.versions_to_test = ['default']
else:
self.versions_to_test = ['9.1_plus']
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "nodes.sql")
-
- template = file_as_template(template_file)
+ cursor = connection.cursor()
+ self.test_setup(connection, cursor)
- sql = template.render(tid=table_id)
+ for version in self.versions_to_test:
+ sql = self.generate_sql(version)
cursor = connection.cursor()
cursor.execute(sql)
fetch_result = cursor.fetchall()
- self.assertEqual(0, len(fetch_result))
+
+ self.assertions(fetch_result, cursor.description)
--
2.12.0
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
@ 2017-05-09 10:01 ` Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Akshay Joshi @ 2017-05-09 10:01 UTC (permalink / raw)
To: Sarah McAlear <[email protected]>; +Cc: Dave Page <[email protected]>; Robert Eckhardt <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Hi Sarah
Below are my review comments on the latest patch:
- Some test file names ended with "*_sql_template.py*" do we need to add
that string ?
- Files "test_column_acl_sql_template.py" and "test_column_properties_sql
_template.py" should be moved from tables->tests to
tables->column->tests. As it's related to column.
- Files "test_trigger_get_oid_sql_template.py" and "test_trigger_nodes_
sql_template.py" should be moved from tables->tests to
tables->triggers->tests. As its related to triggers.
- Following test cases are failing for PG 9.6 and PG 10.0 with error "*name
'long' is not defined". *I am using python 3.5
- TestRoleDependenciesSqlTemplate
- TestTablesPropertiesSqlTemplate
- TestTablesNodeSqlTemplate
On Mon, May 8, 2017 at 9:44 PM, Sarah McAlear <[email protected]> wrote:
> Hi!
>
> This patch has the tests moved to the test directories of the parent.
>
> Thanks,
> Joao & Sarah
>
> On Mon, May 8, 2017 at 7:28 AM, Dave Page <[email protected]> wrote:
>
>> Hi
>>
>> On Mon, May 8, 2017 at 12:24 PM, Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Hi All
>>>
>>> I have reviewed the code and have following questions:
>>>
>>> - Why do we have empty __init__.py file in sql and
>>> templates/<module> folder. In this patch we have couple of occurrences one
>>> of them is web/pgadmin/browser/server_groups/servers/databases/
>>> schemas/table/templates/trigger and web/pgadmin/browser/serve
>>> r_groups/servers/databases/schemas/table/templates/trigger/sql
>>>
>>> That was already answered up-thread: We added the __init__.py files
>> into templates to convert them into packages so that the tests inside of
>> them can be found by the test runner.
>>
>>>
>>> - Why do we have tests folder inside sql folder as we already have
>>> tests folder in respective module. For example we have tests folder in
>>> *web/pgadmin/browser/server_groups/servers/databases/schemas/table/column *then
>>> why do we need it in
>>> *web/pgadmin/browser/server_groups/servers/databases/schemas/table/templates/column/sql/tests*
>>>
>>> That does seem like a valid concern to me.
>>
>>
>>> Apart from above code looks good to me.
>>>
>>> On Mon, May 8, 2017 at 2:20 PM, Akshay Joshi <
>>> [email protected]> wrote:
>>>
>>>>
>>>>
>>>> On Mon, May 8, 2017 at 1:46 PM, Dave Page <[email protected]> wrote:
>>>>
>>>>> Akshay, as Ashesh is unavailable today, can you please review/commit
>>>>> this ASAP?
>>>>>
>>>>
>>>> Sure.
>>>>
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, May 5, 2017 at 1:18 PM, Dave Page <[email protected]> wrote:
>>>>>
>>>>>> Can you get this polished off on Monday please Ashesh?
>>>>>>
>>>>>> On Thu, May 4, 2017 at 12:51 PM, Robert Eckhardt <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> All,
>>>>>>>
>>>>>>> This change in the xss testing is preventing our CI from going green
>>>>>>> and is also preventing the Dependents and Dependencies tabs in Greenplum
>>>>>>> from being useful.
>>>>>>>
>>>>>>> Can we either merge this or provide feedback as to what needs to
>>>>>>> change so that it can be merged.
>>>>>>>
>>>>>>> Thank you
>>>>>>> Rob
>>>>>>>
>>>>>>> On Tue, May 2, 2017 at 5:17 PM, Sarah McAlear <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi Hackers & Ashesh!
>>>>>>>>
>>>>>>>> Is there anything else we can do for this?
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>> Matt & Sarah
>>>>>>>>
>>>>>>>> On Thu, Apr 27, 2017 at 10:37 AM, Joao Pedro De Almeida Pereira <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> Thanks for reviewing, Ashesh.
>>>>>>>>>
>>>>>>>>> We have updated the patch. The headers are all consistent and we
>>>>>>>>> removed the __init__.py files in directories containing only .sql.
>>>>>>>>>
>>>>>>>>> Thanks!
>>>>>>>>> Joao & Matt
>>>>>>>>>
>>>>>>>>> On Wed, Apr 26, 2017 at 11:22 AM, Joao Pedro De Almeida Pereira <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Hello Ashesh,
>>>>>>>>>>
>>>>>>>>>> Thanks for reviewing the patch.
>>>>>>>>>>
>>>>>>>>>> We added the __init__.py files into templates to convert them
>>>>>>>>>> into packages so that the tests inside of them can be found by the test
>>>>>>>>>> runner.
>>>>>>>>>>
>>>>>>>>>> Thanks!
>>>>>>>>>> Joao & Sarah
>>>>>>>>>>
>>>>>>>>>> On Wed, Apr 26, 2017 at 1:26 AM, Ashesh Vashi <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <[email protected]>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Ashesh, can you review/commit this please?
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Apr 21, 2017 at 8:42 PM, Joao Pedro De Almeida Pereira
>>>>>>>>>>>> <[email protected]> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Hackers,
>>>>>>>>>>>>>
>>>>>>>>>>>>> We found out that when you are connected to a GreenPlum
>>>>>>>>>>>>> database and try to get Dependents and Dependencies of an object the
>>>>>>>>>>>>> application was returning a SQL error.
>>>>>>>>>>>>>
>>>>>>>>>>>>> This patch splits the SQL query used to retrieve the
>>>>>>>>>>>>> Dependents, Dependencies, and Roles SQL file into multiple versioned files.
>>>>>>>>>>>>> Add Unit Tests for each file.
>>>>>>>>>>>>> Also added __init__.py files to other test directories to run
>>>>>>>>>>>>> the tests in them.
>>>>>>>>>>>>>
>>>>>>>>>>>> Hi Joao & Sarah,
>>>>>>>>>>>
>>>>>>>>>>> Why do we need to add __init__.py in the template directory?
>>>>>>>>>>> I didn't understand the purpose of the adding __init__.py files
>>>>>>>>>>> in the template directories.
>>>>>>>>>>>
>>>>>>>>>>> NOTE: The headers in those files are not consistent with the
>>>>>>>>>>> other project files.
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>> Thanks & Regards,
>>>>>>>>>>>
>>>>>>>>>>> Ashesh Vashi
>>>>>>>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>>>>>>>> <http://www.enterprisedb.com/;
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>>>>>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>>>>>>>>
>>>>>>>>>>>> Add ORDER BY into Copy Selection Feature test to ensure the
>>>>>>>>>>>>> results are retrieved always in the same order
>>>>>>>>>>>>> Renamed the Scenario of the xss_checks_pgadmin_debugger_test
>>>>>>>>>>>>> and skip it for versions less than 9.1
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>
>>>>>>>>>>>>> Joao & Sarah
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> Sent via pgadmin-hackers mailing list (
>>>>>>>>>>>>> [email protected])
>>>>>>>>>>>>> To make changes to your subscription:
>>>>>>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Dave Page
>>>>>>>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>>>>>>>> Twitter: @pgsnake
>>>>>>>>>>>>
>>>>>>>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Sent via pgadmin-hackers mailing list (
>>>>>>>>> [email protected])
>>>>>>>>> To make changes to your subscription:
>>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Dave Page
>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>> Twitter: @pgsnake
>>>>>>
>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Dave Page
>>>>> Blog: http://pgsnake.blogspot.com
>>>>> Twitter: @pgsnake
>>>>>
>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> *Akshay Joshi*
>>>> *Principal Software Engineer *
>>>>
>>>>
>>>>
>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>
>>>
>>>
>>>
>>> --
>>> *Akshay Joshi*
>>> *Principal Software Engineer *
>>>
>>>
>>>
>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>> 976-788-8246 <+91%2097678%2088246>*
>>>
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
--
*Akshay Joshi*
*Principal Software Engineer *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
@ 2017-05-09 15:33 ` Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Sarah McAlear @ 2017-05-09 15:33 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: Dave Page <[email protected]>; Robert Eckhardt <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Hi Akshay!
> Some test file names ended with "*_sql_template.py*" do we need to add
> that string ?
we added this suffix after moving the tests up a level to tables/tests to
clarify what subject they applied to. we changed the suffix to "_sql.py"
- Files "test_column_acl_sql_template.py" and "test_column_properties_sql_
> template.py" should be moved from tables->tests to tables->column->tests.
> As it's related to column.
> - Files "test_trigger_get_oid_sql_template.py" and "test_trigger_nodes_sql
> _template.py" should be moved from tables->tests to
> tables->triggers->tests. As its related to triggers.
these tests are related to the sql files in tables/templates/column, not
tables/column, so moving them into tables/column would be more confusing.
Following test cases are failing
Thank you, fixed, see new patch. Can you confirm that TestTablesNodeSql
doesn't fail in your environment?
Thanks,
George & Sarah
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] 0001-Fix-error-while-checking-Dependents-and-Dependencies.patch (70.8K, 3-0001-Fix-error-while-checking-Dependents-and-Dependencies.patch)
download | inline diff:
From 0cf1b938ff024e9e9f8c7017b46aaa9c57bfe72f Mon Sep 17 00:00:00 2001
From: George Gelashvili and Sarah McAlear
<[email protected]>
Date: Tue, 9 May 2017 11:30:28 -0400
Subject: [PATCH] Fix error while checking Dependents and Dependencies of
object in GreenPlum:
- Make SQL template UT visible to runtest
- Add SQL to retrieve dependencies for GreenPlum
- Extract Role Dependencies from single dependents file
- Split template for dependents SQL
- Add 'SET LOCAL join_collapse_limit=8;' to dependency/dependents to make them faster. Only caveat is that this will remain unchanged for the session
- Add more expectations to role dependencies
- Specify order of query in copy_selected_query_results_feature_test to make tests pass
- GreenPlum and Postgres order these results differently by default without an order clause specified.
- Skip XSS test for GreenPlum
- Moved tests to the correct folders
---
.../databases/schemas/tables/templates/__init__.py | 0
.../schemas/tables/templates/column/__init__.py | 0
.../templates/column/sql/9.2_plus/__init__.py | 0
.../templates/column/sql/default/__init__.py | 0
.../templates/column/sql/tests/test_column_acl.py | 47 -------------
.../column/sql/tests/test_column_properties.py | 56 ----------------
.../schemas/tables/templates/table/__init__.py | 0
.../schemas/tables/templates/table/sql/__init__.py | 0
.../tables/templates/table/sql/tests/__init__.py | 0
.../templates/table/sql/tests/test_tables_acl.py | 66 -------------------
.../templates/table/sql/tests/test_tables_node.py | 74 ---------------------
.../table/sql/tests/test_tables_properties.py | 77 ----------------------
.../templates/trigger/sql/9.1_plus/__init__.py | 0
.../tables/templates/trigger/sql/__init__.py | 0
.../templates/trigger/sql/default/__init__.py | 0
.../tables/templates/trigger/sql/tests/__init__.py | 0
.../trigger/sql/tests/test_trigger_get_oid.py | 60 -----------------
.../schemas/tables/tests/test_column_acl_sql.py | 51 ++++++++++++++
.../tables/tests/test_column_properties_sql.py | 52 +++++++++++++++
.../schemas/tables/tests/test_tables_acl_sql.py | 54 +++++++++++++++
.../schemas/tables/tests/test_tables_node_sql.py | 55 ++++++++++++++++
.../tables/tests/test_tables_properties_sql.py | 72 ++++++++++++++++++++
.../tables/tests/test_trigger_get_oid_sql.py | 52 +++++++++++++++
.../schemas/tables/tests/test_trigger_nodes_sql.py | 43 ++++++++++++
.../depends/sql/9.1_plus/dependencies.sql | 45 +++++++++++++
.../templates/depends/sql/9.1_plus/dependents.sql | 44 +++++++++++++
.../templates/depends/sql/default/dependencies.sql | 42 ++++++++++++
.../templates/depends/sql/default/dependents.sql | 66 +------------------
.../depends/sql/default/role_dependencies.sql | 4 ++
.../servers/tests/test_dependencies_sql.py | 51 ++++++++++++++
.../servers/tests/test_dependents_sql.py | 51 ++++++++++++++
.../servers/tests/test_role_dependencies_sql.py | 51 ++++++++++++++
web/pgadmin/browser/utils.py | 10 +--
.../copy_selected_query_results_feature_test.py | 11 +++-
.../xss_checks_pgadmin_debugger_test.py | 6 +-
.../python_test_utils/sql_template_test_base.py} | 52 ++++++++-------
36 files changed, 720 insertions(+), 472 deletions(-)
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql.py
rename web/{pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py => regression/python_test_utils/sql_template_test_base.py} (59%)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
deleted file mode 100644
index 7be945c7..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestColumnAcl(BaseTestGenerator):
- def runTest(self):
- """ When there are no permissions on the column, it returns an empty result """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT pg_class.oid as table_id, "
- "pg_attribute.attnum as column_id "
- "FROM pg_class join pg_attribute on attrelid=pg_class.oid "
- "where pg_class.relname='test_table'"
- " and pg_attribute.attname = 'some_column'")
- table_id, column_id = cursor.fetchone()
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "acl.sql")
- template = file_as_template(template_file)
-
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- tid=table_id,
- clid=column_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- self.assertEqual(0, len(fetch_result))
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
deleted file mode 100644
index b1984bda..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
+++ /dev/null
@@ -1,56 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestColumnProperties(BaseTestGenerator):
- def runTest(self):
- """ This tests that column properties are returned"""
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
- table_id = cursor.fetchone()[0]
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "properties.sql")
- template = file_as_template(template_file)
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- tid=table_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- first_row = {}
- for index, description in enumerate(cursor.description):
- first_row[description.name] = fetch_result[0][index]
-
- self.assertEqual('some_column', first_row['name'])
- self.assertEqual('character varying', first_row['cltype'])
- self.assertEqual(2, len(fetch_result))
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py
deleted file mode 100644
index a0f7f94e..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py
+++ /dev/null
@@ -1,66 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTablesAcl(BaseTestGenerator):
- scenarios = [
- ("Test query returns the permissions when there are permissions set up"
- " on the table", dict())
- ]
-
- def runTest(self):
- """ This tests that when there are permissions set up on the table, acl query returns the permissions"""
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("GRANT SELECT ON test_table TO PUBLIC")
-
- cursor = connection.cursor()
- cursor.execute("SELECT oid FROM pg_class WHERE relname='test_table'")
- table_id = cursor.fetchone()[0]
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "acl.sql")
- template = file_as_template(template_file)
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- tid=table_id)
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- public_acls = list(filter(lambda acl: acl[1] == 'PUBLIC', fetch_result))
- self.assertEqual(len(public_acls), 1)
-
- new_acl_map = dict(zip(map(lambda column: column.name, cursor.description), public_acls[0]))
-
- self.assertEqual('PUBLIC', new_acl_map['grantee'])
- self.assertEqual(self.server['username'], new_acl_map['grantor'])
- self.assertEqual('relacl', new_acl_map['deftype'])
- self.assertEqual(['r'], new_acl_map['privileges'])
- self.assertEqual([False], new_acl_map['grantable'])
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py
deleted file mode 100644
index 21ec3275..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py
+++ /dev/null
@@ -1,74 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from jinja2 import BaseLoader
-from jinja2 import Environment
-
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTablesNode(BaseTestGenerator):
- scenarios = [
- ("This scenario tests that all applicable sql template versions can "
- "fetch table names", dict())
- ]
-
- def runTest(self):
- """ This tests that all applicable sql template versions can fetch table names """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- if connection.server_version < 91000:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['default', '9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "nodes.sql")
- file_content = open(template_file, 'r').read()
-
- env = Environment(loader=SimpleTemplateLoader(file_content))
-
- template = env.get_template("")
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id)
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
-
- first_row = {}
- for index, description in enumerate(cursor.description):
- first_row[description.name] = fetch_result[0][index]
-
- oid = first_row['oid']
- name = first_row['name']
- triggercount = first_row['triggercount']
- has_enable_triggers = first_row['has_enable_triggers']
-
- self.assertIsNotNone(long(oid))
- self.assertEqual('test_table', name)
- # triggercount is sometimes returned as a string for some reason
- self.assertEqual(0, long(triggercount))
- self.assertIsNotNone(long(has_enable_triggers))
-
-
-class SimpleTemplateLoader(BaseLoader):
- def __init__(self, file_content):
- self.file_content = file_content
-
- def get_source(self, *args):
- return self.file_content, "required-return-not-a-real-file.txt", True
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py
deleted file mode 100644
index 5984bda5..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py
+++ /dev/null
@@ -1,77 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTablesProperties(BaseTestGenerator):
- scenarios = [
- ("This scenario tests that all applicable sql template versions can "
- "fetch some ddl", dict())
- ]
-
- def runTest(self):
- """ This tests that all applicable sql template versions can fetch some ddl """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute(u"""
- SELECT
- db.oid as did, datlastsysoid
- FROM
- pg_database db
- WHERE db.datname = '{0}'""".format(database_name)
- )
- database_id, last_system_oid = cursor.fetchone()
-
- cursor = connection.cursor()
- cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
- table_id = cursor.fetchone()[0]
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "properties.sql")
- template = file_as_template(template_file)
-
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- did=database_id,
- datlastsysoid=last_system_oid,
- tid=table_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchone()
-
- first_row = {}
- for index, description in enumerate(cursor.description):
- first_row[description.name] = fetch_result[index]
-
- self.assertEqual('test_table', first_row['name'])
- # triggercount is sometimes returned as a string for some reason
- self.assertEqual(0, long(first_row['triggercount']))
- self.assertEqual(None, first_row['typname'])
- self.assertEqual([], first_row['coll_inherits'])
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
deleted file mode 100644
index f2b637ee..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
+++ /dev/null
@@ -1,60 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-import jinja2
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTriggerGetOid(BaseTestGenerator):
- def runTest(self):
- """ When there are no permissions on the column, it returns an empty result """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT pg_class.oid as table_id, "
- "pg_attribute.attnum as column_id "
- "FROM pg_class join pg_attribute on attrelid=pg_class.oid "
- "where pg_class.relname='test_table'"
- " and pg_attribute.attname = 'some_column'")
- table_id, column_id = cursor.fetchone()
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "get_oid.sql")
-
- jinja2.filters.FILTERS['qtLiteral'] = lambda value: "NULL"
- template = file_as_template(template_file)
-
- sql = template.render(data={'name': None},
- tid=table_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- self.assertEqual(0, len(fetch_result))
-
-
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql.py
new file mode 100644
index 00000000..5ba560fd
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestColumnAclSql(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column ACL SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestColumnAclSql, self).__init__()
+ self.table_id = -1
+ self.column_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id, "
+ "pg_attribute.attnum AS column_id "
+ "FROM pg_class JOIN pg_attribute ON attrelid=pg_class.oid "
+ "WHERE pg_class.relname='test_table'"
+ " AND pg_attribute.attname = 'some_column'")
+ self.table_id, self.column_id = cursor.fetchone()
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "acl.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ tid=self.table_id,
+ clid=self.column_id
+ )
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(0, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "column", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql.py
new file mode 100644
index 00000000..ce6fa972
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql.py
@@ -0,0 +1,52 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestColumnPropertiesSql(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column Properties SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestColumnPropertiesSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
+
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "properties.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ tid=self.table_id
+ )
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('some_column', first_row['name'])
+ self.assertEqual('character varying', first_row['cltype'])
+ self.assertEqual(2, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "column", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql.py
new file mode 100644
index 00000000..de49852c
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql.py
@@ -0,0 +1,54 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+from regression.python_test_utils.template_helper import file_as_template
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+
+
+class TestTablesAclSql(SQLTemplateTestBase):
+ scenarios = [
+ ("Test query returns the permissions when there are permissions set up"
+ " on the table", dict())
+ ]
+
+ def __init__(self):
+ super(TestTablesAclSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("GRANT SELECT ON test_table TO PUBLIC")
+ cursor = connection.cursor()
+ cursor.execute("SELECT oid FROM pg_class WHERE relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "acl.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ tid=self.table_id)
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ public_acls = list(filter(lambda acl: acl[1] == 'PUBLIC', fetch_result))
+ self.assertEqual(len(public_acls), 1)
+
+ new_acl_map = dict(zip(map(lambda column: column.name, descriptions), public_acls[0]))
+
+ self.assertEqual('PUBLIC', new_acl_map['grantee'])
+ self.assertEqual(self.server['username'], new_acl_map['grantor'])
+ self.assertEqual('relacl', new_acl_map['deftype'])
+ self.assertEqual(['r'], new_acl_map['privileges'])
+ self.assertEqual([False], new_acl_map['grantable'])
+ return public_acls
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "table", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql.py
new file mode 100644
index 00000000..1f344da3
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql.py
@@ -0,0 +1,55 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+import sys
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestTablesNodeSql(SQLTemplateTestBase):
+ scenarios = [
+ ("This scenario tests that all applicable sql template versions can "
+ "fetch table names", dict())
+ ]
+
+ def test_setup(self, connection, cursor):
+ pass
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "nodes.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id)
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ oid = first_row['oid']
+ name = first_row['name']
+ triggercount = first_row['triggercount']
+ has_enable_triggers = first_row['has_enable_triggers']
+
+ self.assertIsNotNone(long(oid))
+ self.assertEqual('test_table', name)
+ # triggercount is sometimes returned as a string for some reason
+ self.assertEqual(0, long(triggercount))
+ self.assertIsNotNone(long(has_enable_triggers))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "table", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py
new file mode 100644
index 00000000..861562b8
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py
@@ -0,0 +1,72 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+import sys
+
+from regression.python_test_utils.template_helper import file_as_template
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestTablesPropertiesSql(SQLTemplateTestBase):
+ scenarios = [
+ ("This scenario tests that all applicable sql template versions can "
+ "fetch some ddl", dict())
+ ]
+
+ def __init__(self):
+ super(TestTablesPropertiesSql, self).__init__()
+ self.database_id = -1
+ self.last_system_oid = -1
+ self.table_id = -1
+
+ def assertions(self, fetch_result, descriptions):
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('test_table', first_row['name'])
+ # triggercount is sometimes returned as a string for some reason
+ self.assertEqual(0, long(first_row['triggercount']))
+ self.assertEqual(None, first_row['typname'])
+ self.assertEqual([], first_row['coll_inherits'])
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "properties.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ did=self.database_id,
+ datlastsysoid=self.last_system_oid,
+ tid=self.table_id
+ )
+ return sql
+
+ def test_setup(self, connection, cursor):
+ cursor.execute(u"""
+ SELECT
+ db.oid as did, datlastsysoid
+ FROM
+ pg_database db
+ WHERE db.datname = '{0}'""".format(self.database_name)
+ )
+ self.database_id, self.last_system_oid = cursor.fetchone()
+
+ cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "table", "sql", version, filename)
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql.py
new file mode 100644
index 00000000..3306fb7a
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql.py
@@ -0,0 +1,52 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+import jinja2
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestTriggerGetOidSql(SQLTemplateTestBase):
+ scenarios = [
+ ('Test Trigger to retrieve OID SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestTriggerGetOidSql, self).__init__()
+ self.table_id = -1
+ self.column_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id, "
+ "pg_attribute.attnum AS column_id "
+ "FROM pg_class JOIN pg_attribute ON attrelid=pg_class.oid "
+ "WHERE pg_class.relname='test_table'"
+ " AND pg_attribute.attname = 'some_column'")
+ self.table_id, self.column_id = cursor.fetchone()
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "get_oid.sql")
+ jinja2.filters.FILTERS['qtLiteral'] = lambda value: "NULL"
+ template = file_as_template(template_file)
+
+ sql = template.render(data={'name': None},
+ tid=self.table_id
+ )
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(0, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "trigger", "sql", version, filename)
+
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql.py
new file mode 100644
index 00000000..8f328a60
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql.py
@@ -0,0 +1,43 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestTriggerNodesSql(SQLTemplateTestBase):
+ scenarios = [
+ ('Test Trigger Nodes SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestTriggerNodesSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "nodes.sql")
+ template = file_as_template(template_file)
+ sql = template.render(tid=self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(0, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "trigger", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
new file mode 100644
index 00000000..e5bb8cb6
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
@@ -0,0 +1,45 @@
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
new file mode 100644
index 00000000..1281672f
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
@@ -0,0 +1,44 @@
+SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL THEN 'y'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.objid=cl.oid
+LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.objid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.objid=tg.oid
+LEFT JOIN pg_type ty ON dep.objid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.objid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.objid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.objid=la.oid
+LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
+{{where_clause}} AND
+classid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY classid, cl.relkind
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
new file mode 100644
index 00000000..aae5982e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
@@ -0,0 +1,42 @@
+SET LOCAL join_collapse_limit=8;
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
index e2ba3d6b..2fe2ef3e 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
@@ -1,59 +1,4 @@
-{% if fetch_dependencies %}
-SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
- CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
- WHEN tg.oid IS NOT NULL THEN 'T'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
- WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
- WHEN la.oid IS NOT NULL THEN 'l'::text
- WHEN rw.oid IS NOT NULL THEN 'R'::text
- WHEN co.oid IS NOT NULL THEN 'C'::text || contype
- WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
- ELSE ''
- END AS type,
- COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
- END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
-FROM pg_depend dep
-LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
-LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
-LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
-LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
-LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
-LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
-LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
-LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
-LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
-LEFT JOIN pg_class coc ON co.conrelid=coc.oid
-LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
-LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
-LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
-LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
-LEFT JOIN pg_language la ON dep.refobjid=la.oid
-LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
-LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
-{{where_clause}} AND
-refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
- ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
- 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY refclassid, cl.relkind
-{% endif %}
-
-{% if fetch_role_dependencies %}
-SELECT rolname AS refname, refclassid, deptype
-FROM pg_shdepend dep
-LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
-{{where_clause}} ORDER BY 1
-{% endif %}
-
-{% if fetch_dependents %}
+SET LOCAL join_collapse_limit=8;
SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
WHEN tg.oid IS NOT NULL THEN 'T'::text
@@ -64,13 +9,11 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
END AS refname,
COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
FROM pg_depend dep
@@ -91,11 +34,8 @@ LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
LEFT JOIN pg_language la ON dep.objid=la.oid
LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
{{where_clause}} AND
classid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY classid, cl.relkind
-{% endif %}
+ORDER BY classid, cl.relkind;
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
new file mode 100644
index 00000000..25fc3f85
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
@@ -0,0 +1,4 @@
+SELECT rolname AS refname, refclassid, deptype
+FROM pg_shdepend dep
+LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
+{{where_clause}} ORDER BY 1
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql.py b/web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql.py
new file mode 100644
index 00000000..2a0235a2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestDependenciesSql(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestDependenciesSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "dependencies.sql")
+ template = file_as_template(template_file)
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('public', first_row["refname"])
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "depends", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql.py b/web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql.py
new file mode 100644
index 00000000..b82de6d9
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestDependentsSql(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestDependentsSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "dependents.sql")
+ template = file_as_template(template_file)
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('test_table', first_row["refname"])
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "depends", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql.py b/web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql.py
new file mode 100644
index 00000000..65add798
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestRoleDependenciesSql(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Role Dependencies SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestRoleDependenciesSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+ self.versions_to_test = ['default']
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "role_dependencies.sql")
+ template = file_as_template(template_file)
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('o', first_row["deptype"])
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "depends", "sql", version, filename)
diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
index d2899875..708bfdfb 100644
--- a/web/pgadmin/browser/utils.py
+++ b/web/pgadmin/browser/utils.py
@@ -353,15 +353,15 @@ class PGChildNodeView(NodeView):
else:
where_clause = where
- query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependencies=True, where_clause=where_clause)
+ query = render_template("/".join([sql_path, 'dependencies.sql']),
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependencies = self.__fetch_dependency(conn, query)
# fetch role dependencies
if where_clause.find('subid') < 0:
- sql = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_role_dependencies=True, where_clause=where_clause)
+ sql = render_template("/".join([sql_path, 'role_dependencies.sql']),
+ where_clause=where_clause)
status, result = conn.execute_dict(sql)
if not status:
@@ -402,7 +402,7 @@ class PGChildNodeView(NodeView):
where_clause = where
query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependents=True, where_clause=where_clause)
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependents = self.__fetch_dependency(conn, query)
diff --git a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
index 223579ee..338e5f71 100644
--- a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
+++ b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
@@ -1,3 +1,12 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
import pyperclip
import time
@@ -37,7 +46,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
self.page.find_by_partial_link_text("Query Tool").click()
self.page.click_tab('Query-1')
time.sleep(5)
- ActionChains(self.page.driver).send_keys("SELECT * FROM test_table").perform()
+ ActionChains(self.page.driver).send_keys("SELECT * FROM test_table ORDER BY some_column").perform()
self.page.driver.switch_to_frame(self.page.driver.find_element_by_tag_name("iframe"))
self.page.find_by_id("btn-flash").click()
diff --git a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
index 8b018fed..17bc7bf5 100644
--- a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
+++ b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
@@ -16,10 +16,14 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest):
"""Tests to check if Debugger is vulnerable to XSS."""
scenarios = [
- ("Test table DDL generation", dict())
+ ("Tests to check if Debugger is vulnerable to XSS", dict())
]
def before(self):
+ with test_utils.Database(self.server) as (connection, _):
+ if connection.server_version < 90100:
+ self.skipTest("Functions tree node is not present in pgAdmin below PG v9.1")
+
# Some test function is needed for debugger
test_utils.create_debug_function(self.server, "postgres",
"test_function")
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py b/web/regression/python_test_utils/sql_template_test_base.py
similarity index 59%
rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
rename to web/regression/python_test_utils/sql_template_test_base.py
index b23bf60a..8009e31e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
+++ b/web/regression/python_test_utils/sql_template_test_base.py
@@ -7,45 +7,53 @@
#
##########################################################################
-import os
-import sys
-
+from pgadmin.utils.route import BaseTestGenerator
+from regression.python_test_utils import test_utils
from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-if sys.version_info[0] >= 3:
- long = int
+class SQLTemplateTestBase(BaseTestGenerator):
+ scenarios = [
+ ("parent test class", dict(ignore_test=True))
+ ]
+
+ def __init__(self):
+ super(SQLTemplateTestBase, self).__init__()
+ self.database_name = -1
+ self.versions_to_test = -1
+
+ def test_setup(self, connection, cursor):
+ pass
+
+ def generate_sql(self, version):
+ pass
+
+ def assertions(self, fetch_result, descriptions):
+ pass
-class TestTriggerNodes(BaseTestGenerator):
def runTest(self):
- """ When there are no triggers, it returns an empty result """
+ if hasattr(self, "ignore_test"):
+ return
+
with test_utils.Database(self.server) as (connection, database_name):
test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT pg_class.oid AS table_id "
- "FROM pg_class "
- "WHERE pg_class.relname='test_table'")
- table_id = cursor.fetchone()[0]
+ self.database_name = database_name
if connection.server_version < 90100:
self.versions_to_test = ['default']
else:
self.versions_to_test = ['9.1_plus']
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "nodes.sql")
-
- template = file_as_template(template_file)
+ cursor = connection.cursor()
+ self.test_setup(connection, cursor)
- sql = template.render(tid=table_id)
+ for version in self.versions_to_test:
+ sql = self.generate_sql(version)
cursor = connection.cursor()
cursor.execute(sql)
fetch_result = cursor.fetchall()
- self.assertEqual(0, len(fetch_result))
+
+ self.assertions(fetch_result, cursor.description)
--
2.12.0
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
@ 2017-05-10 06:29 ` Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Akshay Joshi @ 2017-05-10 06:29 UTC (permalink / raw)
To: Sarah McAlear <[email protected]>; +Cc: Dave Page <[email protected]>; Robert Eckhardt <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Hi Sarah
On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]> wrote:
> Hi Akshay!
>
>
>> Some test file names ended with "*_sql_template.py*" do we need to add
>> that string ?
>
> we added this suffix after moving the tests up a level to tables/tests to
> clarify what subject they applied to. we changed the suffix to "_sql.py"
>
> - Files "test_column_acl_sql_template.py" and "test_column_properties_sql
>> _template.py" should be moved from tables->tests to
>> tables->column->tests. As it's related to column.
>> - Files "test_trigger_get_oid_sql_template.py" and "test_trigger_nodes_
>> sql_template.py" should be moved from tables->tests to
>> tables->triggers->tests. As its related to triggers.
>
> these tests are related to the sql files in tables/templates/column, not
> tables/column, so moving them into tables/column would be more confusing.
>
> Following test cases are failing
>
> Thank you, fixed, see new patch. Can you confirm that TestTablesNodeSql
> doesn't fail in your environment?
>
TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed with
below error:
.....\test_role_dependencies_sql.py\", line 41, in assertions\n
self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
> Thanks,
> George & Sarah
>
>
--
*Akshay Joshi*
*Principal Software Engineer *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
@ 2017-05-10 13:37 ` Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Sarah McAlear @ 2017-05-10 13:37 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: Dave Page <[email protected]>; Robert Eckhardt <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Matthew Kleiman <[email protected]>
Hi Akshay!
Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all our tests
pass.
Thanks!
João & Sarah
On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <[email protected]
> wrote:
> Hi Sarah
>
> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]> wrote:
>
>> Hi Akshay!
>>
>>
>>> Some test file names ended with "*_sql_template.py*" do we need to add
>>> that string ?
>>
>> we added this suffix after moving the tests up a level to tables/tests to
>> clarify what subject they applied to. we changed the suffix to "_sql.py"
>>
>> - Files "test_column_acl_sql_template.py" and "test_column_properties_sql
>>> _template.py" should be moved from tables->tests to
>>> tables->column->tests. As it's related to column.
>>> - Files "test_trigger_get_oid_sql_template.py" and "test_trigger_nodes_
>>> sql_template.py" should be moved from tables->tests to
>>> tables->triggers->tests. As its related to triggers.
>>
>> these tests are related to the sql files in tables/templates/column, not
>> tables/column, so moving them into tables/column would be more confusing.
>>
>> Following test cases are failing
>>
>> Thank you, fixed, see new patch. Can you confirm that TestTablesNodeSql
>> doesn't fail in your environment?
>>
>
> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed
> with below error:
> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>
>
>> Thanks,
>> George & Sarah
>>
>>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91 976-788-8246
> <+91%2097678%2088246>*
>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
@ 2017-05-10 17:56 ` Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Akshay Joshi @ 2017-05-10 17:56 UTC (permalink / raw)
To: Sarah McAlear <[email protected]>; +Cc: Joao Pedro De Almeida Pereira <[email protected]>; Robert Eckhardt <[email protected]>; Matthew Kleiman <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Dave Page <[email protected]>
On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
Hi Akshay!
Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all our tests
pass.
On both 9.6 and 10.0. Query returned 0 rows which is compared against 1
in assert statement.
Thanks!
João & Sarah
On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <[email protected]
> wrote:
> Hi Sarah
>
> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]> wrote:
>
>> Hi Akshay!
>>
>>
>>> Some test file names ended with "*_sql_template.py*" do we need to add
>>> that string ?
>>
>> we added this suffix after moving the tests up a level to tables/tests to
>> clarify what subject they applied to. we changed the suffix to "_sql.py"
>>
>> - Files "test_column_acl_sql_template.py" and "test_column_properties_sql
>>> _template.py" should be moved from tables->tests to
>>> tables->column->tests. As it's related to column.
>>> - Files "test_trigger_get_oid_sql_template.py" and "test_trigger_nodes_
>>> sql_template.py" should be moved from tables->tests to
>>> tables->triggers->tests. As its related to triggers.
>>
>> these tests are related to the sql files in tables/templates/column, not
>> tables/column, so moving them into tables/column would be more confusing.
>>
>> Following test cases are failing
>>
>> Thank you, fixed, see new patch. Can you confirm that TestTablesNodeSql
>> doesn't fail in your environment?
>>
>
> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed
> with below error:
> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>
>
>> Thanks,
>> George & Sarah
>>
>>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91 976-788-8246
> <+91%2097678%2088246>*
>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
@ 2017-05-10 21:00 ` Sarah McAlear <[email protected]>
2017-05-11 06:11 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Sarah McAlear @ 2017-05-10 21:00 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: Joao Pedro De Almeida Pereira <[email protected]>; Robert Eckhardt <[email protected]>; Matthew Kleiman <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Dave Page <[email protected]>
Hi Ashkay!
TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed with
> below error:
> .....\test_role_dependencies_sql.py\", line 41, in assertions\n self.assertEqual(1,
> len(fetch_result))\nAssertionError: 1 != 0
We experienced a similar problem when we started developing this patch. We
noticed that we were connecting to the database with the super user (the db
owner user), which did not create the role we are expecting when a table is
created. To ensure that this role is created, we had to create a new user
and use it to execute all the tests. After we made this change, the tests
passed.
Can you try to create a new user and use it to execute your tests?
Thanks,
João & Sarah
On Wed, May 10, 2017 at 1:56 PM, Akshay Joshi <[email protected]
> wrote:
>
>
> On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
>
> Hi Akshay!
>
> Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all our
> tests pass.
>
>
> On both 9.6 and 10.0. Query returned 0 rows which is compared against
> 1 in assert statement.
>
>
> Thanks!
> João & Sarah
>
> On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <
> [email protected]> wrote:
>
>> Hi Sarah
>>
>> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]>
>> wrote:
>>
>>> Hi Akshay!
>>>
>>>
>>>> Some test file names ended with "*_sql_template.py*" do we need to add
>>>> that string ?
>>>
>>> we added this suffix after moving the tests up a level to tables/tests
>>> to clarify what subject they applied to. we changed the suffix to "_sql.py"
>>>
>>> - Files "test_column_acl_sql_template.py" and "test_column_properties_
>>>> sql_template.py" should be moved from tables->tests to
>>>> tables->column->tests. As it's related to column.
>>>> - Files "test_trigger_get_oid_sql_template.py" and "test_trigger_nodes_
>>>> sql_template.py" should be moved from tables->tests to
>>>> tables->triggers->tests. As its related to triggers.
>>>
>>> these tests are related to the sql files in tables/templates/column, not
>>> tables/column, so moving them into tables/column would be more confusing.
>>>
>>> Following test cases are failing
>>>
>>> Thank you, fixed, see new patch. Can you confirm that TestTablesNodeSql
>>> doesn't fail in your environment?
>>>
>>
>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed
>> with below error:
>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>
>>
>>> Thanks,
>>> George & Sarah
>>>
>>>
>>
>>
>> --
>> *Akshay Joshi*
>> *Principal Software Engineer *
>>
>>
>>
>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91 976-788-8246
>> <+91%2097678%2088246>*
>>
>
>
>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
@ 2017-05-11 06:11 ` Akshay Joshi <[email protected]>
2017-05-11 06:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Akshay Joshi @ 2017-05-11 06:11 UTC (permalink / raw)
To: Sarah McAlear <[email protected]>; +Cc: Joao Pedro De Almeida Pereira <[email protected]>; Robert Eckhardt <[email protected]>; Matthew Kleiman <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers; Dave Page <[email protected]>
Hi Sarah
On Thu, May 11, 2017 at 2:30 AM, Sarah McAlear <[email protected]> wrote:
> Hi Ashkay!
>
> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed with
>> below error:
>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>
>
> We experienced a similar problem when we started developing this patch. We
> noticed that we were connecting to the database with the super user (the db
> owner user), which did not create the role we are expecting when a table is
> created. To ensure that this role is created, we had to create a new user
> and use it to execute all the tests. After we made this change, the tests
> passed.
>
> Can you try to create a new user and use it to execute your tests?
>
I did that and it works. I have created new user 'test' with superuser
privileges and update parameter db_username="test" in test_config.json
file. But still I am unable to understand why it doesn't work with
'postgres' (default) user?
>
> Thanks,
> João & Sarah
>
> On Wed, May 10, 2017 at 1:56 PM, Akshay Joshi <
> [email protected]> wrote:
>
>>
>>
>> On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
>>
>> Hi Akshay!
>>
>> Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all our
>> tests pass.
>>
>>
>> On both 9.6 and 10.0. Query returned 0 rows which is compared against
>> 1 in assert statement.
>>
>>
>> Thanks!
>> João & Sarah
>>
>> On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Hi Sarah
>>>
>>> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]>
>>> wrote:
>>>
>>>> Hi Akshay!
>>>>
>>>>
>>>>> Some test file names ended with "*_sql_template.py*" do we need to
>>>>> add that string ?
>>>>
>>>> we added this suffix after moving the tests up a level to tables/tests
>>>> to clarify what subject they applied to. we changed the suffix to "_sql.py"
>>>>
>>>> - Files "test_column_acl_sql_template.py" and "test_column_properties_
>>>>> sql_template.py" should be moved from tables->tests to
>>>>> tables->column->tests. As it's related to column.
>>>>> - Files "test_trigger_get_oid_sql_template.py" and "
>>>>> test_trigger_nodes_sql_template.py" should be moved from
>>>>> tables->tests to tables->triggers->tests. As its related to triggers.
>>>>
>>>> these tests are related to the sql files in tables/templates/column,
>>>> not tables/column, so moving them into tables/column would be more
>>>> confusing.
>>>>
>>>> Following test cases are failing
>>>>
>>>> Thank you, fixed, see new patch. Can you confirm that TestTablesNodeSql
>>>> doesn't fail in your environment?
>>>>
>>>
>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed
>>> with below error:
>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>
>>>
>>>> Thanks,
>>>> George & Sarah
>>>>
>>>>
>>>
>>>
>>> --
>>> *Akshay Joshi*
>>> *Principal Software Engineer *
>>>
>>>
>>>
>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>> 976-788-8246 <+91%2097678%2088246>*
>>>
>>
>>
>>
>
--
*Akshay Joshi*
*Principal Software Engineer *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-11 06:11 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
@ 2017-05-11 06:33 ` Dave Page <[email protected]>
2017-05-11 07:20 ` Re: [patch] Dependents and Dependencies in GreenPlum Khushboo Vashi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Dave Page @ 2017-05-11 06:33 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: Sarah McAlear <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Robert Eckhardt <[email protected]>; Matthew Kleiman <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers
> On 11 May 2017, at 07:11, Akshay Joshi <[email protected]> wrote:
>
> Hi Sarah
>
>> On Thu, May 11, 2017 at 2:30 AM, Sarah McAlear <[email protected]> wrote:
>> Hi Ashkay!
>>
>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed with below error:
>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>
>>
>> We experienced a similar problem when we started developing this patch. We noticed that we were connecting to the database with the super user (the db owner user), which did not create the role we are expecting when a table is created. To ensure that this role is created, we had to create a new user and use it to execute all the tests. After we made this change, the tests passed.
>>
>> Can you try to create a new user and use it to execute your tests?
>
> I did that and it works. I have created new user 'test' with superuser privileges and update parameter db_username="test" in test_config.json file. But still I am unable to understand why it doesn't work with 'postgres' (default) user?
Agreed. That suggests something fishy is going on that should be understood.
>>
>> Thanks,
>> João & Sarah
>>
>>> On Wed, May 10, 2017 at 1:56 PM, Akshay Joshi <[email protected]> wrote:
>>>
>>>
>>> On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
>>> Hi Akshay!
>>>
>>> Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all our tests pass.
>>>
>>> On both 9.6 and 10.0. Query returned 0 rows which is compared against 1 in assert statement.
>>>
>>> Thanks!
>>> João & Sarah
>>>
>>>> On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <[email protected]> wrote:
>>>> Hi Sarah
>>>>
>>>>> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]> wrote:
>>>>> Hi Akshay!
>>>>>
>>>>>> Some test file names ended with "_sql_template.py" do we need to add that string ?
>>>>>
>>>>> we added this suffix after moving the tests up a level to tables/tests to clarify what subject they applied to. we changed the suffix to "_sql.py"
>>>>>
>>>>>> - Files "test_column_acl_sql_template.py" and "test_column_properties_sql_template.py" should be moved from tables->tests to tables->column->tests. As it's related to column.
>>>>>> - Files "test_trigger_get_oid_sql_template.py" and "test_trigger_nodes_sql_template.py" should be moved from tables->tests to tables->triggers->tests. As its related to triggers.
>>>>> these tests are related to the sql files in tables/templates/column, not tables/column, so moving them into tables/column would be more confusing.
>>>>>
>>>>>> Following test cases are failing
>>>>>
>>>>> Thank you, fixed, see new patch. Can you confirm that TestTablesNodeSql doesn't fail in your environment?
>>>>
>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed with below error:
>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>
>>>>>
>>>>> Thanks,
>>>>> George & Sarah
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Akshay Joshi
>>>> Principal Software Engineer
>>>>
>>>>
>>>>
>>>> Phone: +91 20-3058-9517
>>>> Mobile: +91 976-788-8246
>>>
>>>
>>
>
>
>
> --
> Akshay Joshi
> Principal Software Engineer
>
>
>
> Phone: +91 20-3058-9517
> Mobile: +91 976-788-8246
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-11 06:11 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-11 06:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
@ 2017-05-11 07:20 ` Khushboo Vashi <[email protected]>
2017-05-11 11:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Khushboo Vashi @ 2017-05-11 07:20 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: Akshay Joshi <[email protected]>; Sarah McAlear <[email protected]>; Joao Pedro De Almeida Pereira <[email protected]>; Robert Eckhardt <[email protected]>; Matthew Kleiman <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers
On Thu, May 11, 2017 at 12:03 PM, Dave Page <[email protected]> wrote:
>
>
> On 11 May 2017, at 07:11, Akshay Joshi <[email protected]>
> wrote:
>
> Hi Sarah
>
> On Thu, May 11, 2017 at 2:30 AM, Sarah McAlear <[email protected]>
> wrote:
>
>> Hi Ashkay!
>>
>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed with
>>> below error:
>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>
>>
>> We experienced a similar problem when we started developing this patch.
>> We noticed that we were connecting to the database with the super user (the
>> db owner user), which did not create the role we are expecting when a table
>> is created. To ensure that this role is created, we had to create a new
>> user and use it to execute all the tests. After we made this change, the
>> tests passed.
>>
>> Can you try to create a new user and use it to execute your tests?
>>
>
> I did that and it works. I have created new user 'test' with superuser
> privileges and update parameter db_username="test" in test_config.json
> file. But still I am unable to understand why it doesn't work with
> 'postgres' (default) user?
>
>
> Agreed. That suggests something fishy is going on that should be
> understood.
>
>
We don't check role dependencies for every object. As per the code, the
role dependencies are executed for columns not for the table itself.
And in the test cases, the table object is trying to execute the role
dependencies, so I think this test case is not correct.
>
>> Thanks,
>> João & Sarah
>>
>> On Wed, May 10, 2017 at 1:56 PM, Akshay Joshi <
>> [email protected]> wrote:
>>
>>>
>>>
>>> On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
>>>
>>> Hi Akshay!
>>>
>>> Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all our
>>> tests pass.
>>>
>>>
>>> On both 9.6 and 10.0. Query returned 0 rows which is compared
>>> against 1 in assert statement.
>>>
>>>
>>> Thanks!
>>> João & Sarah
>>>
>>> On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <
>>> [email protected]> wrote:
>>>
>>>> Hi Sarah
>>>>
>>>> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi Akshay!
>>>>>
>>>>>
>>>>>> Some test file names ended with "*_sql_template.py*" do we need to
>>>>>> add that string ?
>>>>>
>>>>> we added this suffix after moving the tests up a level to tables/tests
>>>>> to clarify what subject they applied to. we changed the suffix to "_sql.py"
>>>>>
>>>>> - Files "test_column_acl_sql_template.py" and "test_column_properties_
>>>>>> sql_template.py" should be moved from tables->tests to
>>>>>> tables->column->tests. As it's related to column.
>>>>>> - Files "test_trigger_get_oid_sql_template.py" and "
>>>>>> test_trigger_nodes_sql_template.py" should be moved from
>>>>>> tables->tests to tables->triggers->tests. As its related to triggers.
>>>>>
>>>>> these tests are related to the sql files in tables/templates/column,
>>>>> not tables/column, so moving them into tables/column would be more
>>>>> confusing.
>>>>>
>>>>> Following test cases are failing
>>>>>
>>>>> Thank you, fixed, see new patch. Can you confirm that
>>>>> TestTablesNodeSql doesn't fail in your environment?
>>>>>
>>>>
>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed
>>>> with below error:
>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>
>>>>
>>>>> Thanks,
>>>>> George & Sarah
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Akshay Joshi*
>>>> *Principal Software Engineer *
>>>>
>>>>
>>>>
>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>
>>>
>>>
>>>
>>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>
>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-11 06:11 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-11 06:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-11 07:20 ` Re: [patch] Dependents and Dependencies in GreenPlum Khushboo Vashi <[email protected]>
@ 2017-05-11 11:33 ` Joao Pedro De Almeida Pereira <[email protected]>
2017-05-12 17:53 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Joao Pedro De Almeida Pereira @ 2017-05-11 11:33 UTC (permalink / raw)
To: Khushboo Vashi <[email protected]>; Dave Page <[email protected]>; +Cc: Akshay Joshi <[email protected]>; Sarah McAlear <[email protected]>; Robert Eckhardt <[email protected]>; Matthew Kleiman <[email protected]>; Ashesh Vashi <[email protected]>; pgadmin-hackers
Hello all,
This test is trying to check if the sql to retrieve the role dependencies
of a object in the database is correct. Using a different user to connect
to the database and create tables there is no need for extra setup because
the role depedencies table entry is added automatically. Also we talked
with some internal users and they told us they always used a different user
to connect to the database with pgadmin.
After your comments we realize that the test need to have a different setup
in order to become more readable and resilient. What do we need to do in
the test setup to ensure an entry is added to the role dependency table?
Also the test need to be a little bit more resilient to work independently
of the user that is used on the test.
Thanks
Joao
On Thu, May 11, 2017, 3:20 AM Khushboo Vashi <
[email protected]> wrote:
> On Thu, May 11, 2017 at 12:03 PM, Dave Page <[email protected]> wrote:
>
>>
>>
>> On 11 May 2017, at 07:11, Akshay Joshi <[email protected]>
>> wrote:
>>
>> Hi Sarah
>>
>> On Thu, May 11, 2017 at 2:30 AM, Sarah McAlear <[email protected]>
>> wrote:
>>
>>> Hi Ashkay!
>>>
>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed with
>>>> below error:
>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n self.assertEqual(1,
>>>> len(fetch_result))\nAssertionError: 1 != 0
>>>
>>>
>>> We experienced a similar problem when we started developing this patch.
>>> We noticed that we were connecting to the database with the super user (the
>>> db owner user), which did not create the role we are expecting when a table
>>> is created. To ensure that this role is created, we had to create a new
>>> user and use it to execute all the tests. After we made this change, the
>>> tests passed.
>>>
>>> Can you try to create a new user and use it to execute your tests?
>>>
>>
>> I did that and it works. I have created new user 'test' with
>> superuser privileges and update parameter db_username="test" in
>> test_config.json file. But still I am unable to understand why it doesn't
>> work with 'postgres' (default) user?
>>
>>
>> Agreed. That suggests something fishy is going on that should be
>> understood.
>>
>>
> We don't check role dependencies for every object. As per the code, the
> role dependencies are executed for columns not for the table itself.
> And in the test cases, the table object is trying to execute the role
> dependencies, so I think this test case is not correct.
>
>>
>>> Thanks,
>>> João & Sarah
>>>
>>> On Wed, May 10, 2017 at 1:56 PM, Akshay Joshi <
>>> [email protected]> wrote:
>>>
>>>>
>>>>
>>>> On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
>>>>
>>>> Hi Akshay!
>>>>
>>>> Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all our
>>>> tests pass.
>>>>
>>>>
>>>> On both 9.6 and 10.0. Query returned 0 rows which is compared
>>>> against 1 in assert statement.
>>>>
>>>>
>>>> Thanks!
>>>> João & Sarah
>>>>
>>>> On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Sarah
>>>>>
>>>>> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hi Akshay!
>>>>>>
>>>>>>
>>>>>>> Some test file names ended with "*_sql_template.py*" do we need to
>>>>>>> add that string ?
>>>>>>
>>>>>> we added this suffix after moving the tests up a level to
>>>>>> tables/tests to clarify what subject they applied to. we changed the suffix
>>>>>> to "_sql.py"
>>>>>>
>>>>>> - Files "test_column_acl_sql_template.py" and "
>>>>>>> test_column_properties_sql_template.py" should be moved from
>>>>>>> tables->tests to tables->column->tests. As it's related to column.
>>>>>>> - Files "test_trigger_get_oid_sql_template.py" and "
>>>>>>> test_trigger_nodes_sql_template.py" should be moved from
>>>>>>> tables->tests to tables->triggers->tests. As its related to triggers.
>>>>>>
>>>>>> these tests are related to the sql files in tables/templates/column,
>>>>>> not tables/column, so moving them into tables/column would be more
>>>>>> confusing.
>>>>>>
>>>>>> Following test cases are failing
>>>>>>
>>>>>> Thank you, fixed, see new patch. Can you confirm that
>>>>>> TestTablesNodeSql doesn't fail in your environment?
>>>>>>
>>>>>
>>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed
>>>>> with below error:
>>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>>
>>>>>
>>>>>> Thanks,
>>>>>> George & Sarah
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Akshay Joshi*
>>>>> *Principal Software Engineer *
>>>>>
>>>>>
>>>>>
>>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>> *Akshay Joshi*
>> *Principal Software Engineer *
>>
>>
>>
>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>
>>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-11 06:11 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-11 06:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-11 07:20 ` Re: [patch] Dependents and Dependencies in GreenPlum Khushboo Vashi <[email protected]>
2017-05-11 11:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
@ 2017-05-12 17:53 ` Joao Pedro De Almeida Pereira <[email protected]>
2017-05-14 08:52 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Joao Pedro De Almeida Pereira @ 2017-05-12 17:53 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers; George Gelashvili <[email protected]>
Hello Akshay,
You can find attached a new version of the patch that changes the test in
question.
This new version instead of requiring a creation of a new Role now does the
following:
1 - Creates a new Role
2 - Creates a table with that Role
3 - Checks for dependencies
Thanks
Joao & George
On Thu, May 11, 2017 at 7:33 AM, Joao Pedro De Almeida Pereira <
[email protected]> wrote:
> Hello all,
> This test is trying to check if the sql to retrieve the role dependencies
> of a object in the database is correct. Using a different user to connect
> to the database and create tables there is no need for extra setup because
> the role depedencies table entry is added automatically. Also we talked
> with some internal users and they told us they always used a different user
> to connect to the database with pgadmin.
>
> After your comments we realize that the test need to have a different
> setup in order to become more readable and resilient. What do we need to do
> in the test setup to ensure an entry is added to the role dependency table?
>
> Also the test need to be a little bit more resilient to work independently
> of the user that is used on the test.
>
> Thanks
> Joao
>
> On Thu, May 11, 2017, 3:20 AM Khushboo Vashi <khushboo.vashi@enterprisedb.
> com> wrote:
>
>> On Thu, May 11, 2017 at 12:03 PM, Dave Page <[email protected]> wrote:
>>
>>>
>>>
>>> On 11 May 2017, at 07:11, Akshay Joshi <[email protected]>
>>> wrote:
>>>
>>> Hi Sarah
>>>
>>> On Thu, May 11, 2017 at 2:30 AM, Sarah McAlear <[email protected]>
>>> wrote:
>>>
>>>> Hi Ashkay!
>>>>
>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed with
>>>>> below error:
>>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>
>>>>
>>>> We experienced a similar problem when we started developing this patch.
>>>> We noticed that we were connecting to the database with the super user (the
>>>> db owner user), which did not create the role we are expecting when a table
>>>> is created. To ensure that this role is created, we had to create a new
>>>> user and use it to execute all the tests. After we made this change, the
>>>> tests passed.
>>>>
>>>> Can you try to create a new user and use it to execute your tests?
>>>>
>>>
>>> I did that and it works. I have created new user 'test' with
>>> superuser privileges and update parameter db_username="test" in
>>> test_config.json file. But still I am unable to understand why it doesn't
>>> work with 'postgres' (default) user?
>>>
>>>
>>> Agreed. That suggests something fishy is going on that should be
>>> understood.
>>>
>>>
>> We don't check role dependencies for every object. As per the code, the
>> role dependencies are executed for columns not for the table itself.
>> And in the test cases, the table object is trying to execute the role
>> dependencies, so I think this test case is not correct.
>>
>>>
>>>> Thanks,
>>>> João & Sarah
>>>>
>>>> On Wed, May 10, 2017 at 1:56 PM, Akshay Joshi <
>>>> [email protected]> wrote:
>>>>
>>>>>
>>>>>
>>>>> On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
>>>>>
>>>>> Hi Akshay!
>>>>>
>>>>> Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all our
>>>>> tests pass.
>>>>>
>>>>>
>>>>> On both 9.6 and 10.0. Query returned 0 rows which is compared
>>>>> against 1 in assert statement.
>>>>>
>>>>>
>>>>> Thanks!
>>>>> João & Sarah
>>>>>
>>>>> On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi Sarah
>>>>>>
>>>>>> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Akshay!
>>>>>>>
>>>>>>>
>>>>>>>> Some test file names ended with "*_sql_template.py*" do we need to
>>>>>>>> add that string ?
>>>>>>>
>>>>>>> we added this suffix after moving the tests up a level to
>>>>>>> tables/tests to clarify what subject they applied to. we changed the suffix
>>>>>>> to "_sql.py"
>>>>>>>
>>>>>>> - Files "test_column_acl_sql_template.py" and "
>>>>>>>> test_column_properties_sql_template.py" should be moved from
>>>>>>>> tables->tests to tables->column->tests. As it's related to column.
>>>>>>>> - Files "test_trigger_get_oid_sql_template.py" and "
>>>>>>>> test_trigger_nodes_sql_template.py" should be moved from
>>>>>>>> tables->tests to tables->triggers->tests. As its related to triggers.
>>>>>>>
>>>>>>> these tests are related to the sql files in tables/templates/column,
>>>>>>> not tables/column, so moving them into tables/column would be more
>>>>>>> confusing.
>>>>>>>
>>>>>>> Following test cases are failing
>>>>>>>
>>>>>>> Thank you, fixed, see new patch. Can you confirm that
>>>>>>> TestTablesNodeSql doesn't fail in your environment?
>>>>>>>
>>>>>>
>>>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql
>>>>>> failed with below error:
>>>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>>>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>>>
>>>>>>
>>>>>>> Thanks,
>>>>>>> George & Sarah
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Akshay Joshi*
>>>>>> *Principal Software Engineer *
>>>>>>
>>>>>>
>>>>>>
>>>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> *Akshay Joshi*
>>> *Principal Software Engineer *
>>>
>>>
>>>
>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>> 976-788-8246 <+91%2097678%2088246>*
>>>
>>>
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] 0001-Fix-error-while-checking-Dependents-and-Dependencies.patch (71.9K, 3-0001-Fix-error-while-checking-Dependents-and-Dependencies.patch)
download | inline diff:
From 769168774eff95138b09cf52a3913c38949d65f1 Mon Sep 17 00:00:00 2001
From: George Gelashvili and Joao Pereira
<[email protected]>
Date: Fri, 12 May 2017 12:32:16 -0400
Subject: [PATCH] Fix error while checking Dependents and Dependencies of
object in GreenPlum:
- Make SQL template UT visible to runtest
- Add SQL to retrieve dependencies for GreenPlum
- Extract Role Dependencies from single dependents file
- Split template for dependents SQL
- Add 'SET LOCAL join_collapse_limit=8;' to dependency/dependents to make them faster. Only caveat is that this will remain unchanged for the session
- Add more expectations to role dependencies
- Specify order of query in copy_selected_query_results_feature_test to make tests pass
- GreenPlum and Postgres order these results differently by default without an order clause specified.
- Skip XSS test for GreenPlum
- Moved tests to the correct folders
---
.../databases/schemas/tables/templates/__init__.py | 0
.../schemas/tables/templates/column/__init__.py | 0
.../templates/column/sql/9.2_plus/__init__.py | 0
.../templates/column/sql/default/__init__.py | 0
.../templates/column/sql/tests/test_column_acl.py | 47 -------------
.../column/sql/tests/test_column_properties.py | 56 ----------------
.../schemas/tables/templates/table/__init__.py | 0
.../schemas/tables/templates/table/sql/__init__.py | 0
.../tables/templates/table/sql/tests/__init__.py | 0
.../templates/table/sql/tests/test_tables_acl.py | 66 -------------------
.../templates/table/sql/tests/test_tables_node.py | 74 ---------------------
.../table/sql/tests/test_tables_properties.py | 77 ----------------------
.../templates/trigger/sql/9.1_plus/__init__.py | 0
.../tables/templates/trigger/sql/__init__.py | 0
.../templates/trigger/sql/default/__init__.py | 0
.../tables/templates/trigger/sql/tests/__init__.py | 0
.../trigger/sql/tests/test_trigger_get_oid.py | 60 -----------------
.../schemas/tables/tests/test_column_acl_sql.py | 51 ++++++++++++++
.../tables/tests/test_column_properties_sql.py | 52 +++++++++++++++
.../schemas/tables/tests/test_tables_acl_sql.py | 54 +++++++++++++++
.../schemas/tables/tests/test_tables_node_sql.py | 55 ++++++++++++++++
.../tables/tests/test_tables_properties_sql.py | 72 ++++++++++++++++++++
.../tables/tests/test_trigger_get_oid_sql.py | 52 +++++++++++++++
.../schemas/tables/tests/test_trigger_nodes_sql.py | 43 ++++++++++++
.../depends/sql/9.1_plus/dependencies.sql | 45 +++++++++++++
.../templates/depends/sql/9.1_plus/dependents.sql | 44 +++++++++++++
.../templates/depends/sql/default/dependencies.sql | 42 ++++++++++++
.../templates/depends/sql/default/dependents.sql | 66 +------------------
.../depends/sql/default/role_dependencies.sql | 4 ++
.../servers/tests/test_dependencies_sql.py | 51 ++++++++++++++
.../servers/tests/test_dependents_sql.py | 51 ++++++++++++++
.../servers/tests/test_role_dependencies_sql.py | 76 +++++++++++++++++++++
web/pgadmin/browser/utils.py | 10 +--
.../copy_selected_query_results_feature_test.py | 11 +++-
.../xss_checks_pgadmin_debugger_test.py | 6 +-
.../python_test_utils/sql_template_test_base.py} | 52 ++++++++-------
36 files changed, 745 insertions(+), 472 deletions(-)
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py
delete mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
create mode 100644 web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql.py
create mode 100644 web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql.py
rename web/{pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py => regression/python_test_utils/sql_template_test_base.py} (59%)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
deleted file mode 100644
index 7be945c7..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_acl.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestColumnAcl(BaseTestGenerator):
- def runTest(self):
- """ When there are no permissions on the column, it returns an empty result """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT pg_class.oid as table_id, "
- "pg_attribute.attnum as column_id "
- "FROM pg_class join pg_attribute on attrelid=pg_class.oid "
- "where pg_class.relname='test_table'"
- " and pg_attribute.attname = 'some_column'")
- table_id, column_id = cursor.fetchone()
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "acl.sql")
- template = file_as_template(template_file)
-
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- tid=table_id,
- clid=column_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- self.assertEqual(0, len(fetch_result))
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
deleted file mode 100644
index b1984bda..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/tests/test_column_properties.py
+++ /dev/null
@@ -1,56 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestColumnProperties(BaseTestGenerator):
- def runTest(self):
- """ This tests that column properties are returned"""
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
- table_id = cursor.fetchone()[0]
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "properties.sql")
- template = file_as_template(template_file)
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- tid=table_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- first_row = {}
- for index, description in enumerate(cursor.description):
- first_row[description.name] = fetch_result[0][index]
-
- self.assertEqual('some_column', first_row['name'])
- self.assertEqual('character varying', first_row['cltype'])
- self.assertEqual(2, len(fetch_result))
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py
deleted file mode 100644
index a0f7f94e..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_acl.py
+++ /dev/null
@@ -1,66 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTablesAcl(BaseTestGenerator):
- scenarios = [
- ("Test query returns the permissions when there are permissions set up"
- " on the table", dict())
- ]
-
- def runTest(self):
- """ This tests that when there are permissions set up on the table, acl query returns the permissions"""
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("GRANT SELECT ON test_table TO PUBLIC")
-
- cursor = connection.cursor()
- cursor.execute("SELECT oid FROM pg_class WHERE relname='test_table'")
- table_id = cursor.fetchone()[0]
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "acl.sql")
- template = file_as_template(template_file)
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- tid=table_id)
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- public_acls = list(filter(lambda acl: acl[1] == 'PUBLIC', fetch_result))
- self.assertEqual(len(public_acls), 1)
-
- new_acl_map = dict(zip(map(lambda column: column.name, cursor.description), public_acls[0]))
-
- self.assertEqual('PUBLIC', new_acl_map['grantee'])
- self.assertEqual(self.server['username'], new_acl_map['grantor'])
- self.assertEqual('relacl', new_acl_map['deftype'])
- self.assertEqual(['r'], new_acl_map['privileges'])
- self.assertEqual([False], new_acl_map['grantable'])
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py
deleted file mode 100644
index 21ec3275..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_node.py
+++ /dev/null
@@ -1,74 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from jinja2 import BaseLoader
-from jinja2 import Environment
-
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTablesNode(BaseTestGenerator):
- scenarios = [
- ("This scenario tests that all applicable sql template versions can "
- "fetch table names", dict())
- ]
-
- def runTest(self):
- """ This tests that all applicable sql template versions can fetch table names """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- if connection.server_version < 91000:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['default', '9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "nodes.sql")
- file_content = open(template_file, 'r').read()
-
- env = Environment(loader=SimpleTemplateLoader(file_content))
-
- template = env.get_template("")
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id)
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
-
- first_row = {}
- for index, description in enumerate(cursor.description):
- first_row[description.name] = fetch_result[0][index]
-
- oid = first_row['oid']
- name = first_row['name']
- triggercount = first_row['triggercount']
- has_enable_triggers = first_row['has_enable_triggers']
-
- self.assertIsNotNone(long(oid))
- self.assertEqual('test_table', name)
- # triggercount is sometimes returned as a string for some reason
- self.assertEqual(0, long(triggercount))
- self.assertIsNotNone(long(has_enable_triggers))
-
-
-class SimpleTemplateLoader(BaseLoader):
- def __init__(self, file_content):
- self.file_content = file_content
-
- def get_source(self, *args):
- return self.file_content, "required-return-not-a-real-file.txt", True
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py
deleted file mode 100644
index 5984bda5..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/tests/test_tables_properties.py
+++ /dev/null
@@ -1,77 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTablesProperties(BaseTestGenerator):
- scenarios = [
- ("This scenario tests that all applicable sql template versions can "
- "fetch some ddl", dict())
- ]
-
- def runTest(self):
- """ This tests that all applicable sql template versions can fetch some ddl """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute(u"""
- SELECT
- db.oid as did, datlastsysoid
- FROM
- pg_database db
- WHERE db.datname = '{0}'""".format(database_name)
- )
- database_id, last_system_oid = cursor.fetchone()
-
- cursor = connection.cursor()
- cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
- table_id = cursor.fetchone()[0]
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "properties.sql")
- template = file_as_template(template_file)
-
- public_schema_id = 2200
- sql = template.render(scid=public_schema_id,
- did=database_id,
- datlastsysoid=last_system_oid,
- tid=table_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchone()
-
- first_row = {}
- for index, description in enumerate(cursor.description):
- first_row[description.name] = fetch_result[index]
-
- self.assertEqual('test_table', first_row['name'])
- # triggercount is sometimes returned as a string for some reason
- self.assertEqual(0, long(first_row['triggercount']))
- self.assertEqual(None, first_row['typname'])
- self.assertEqual([], first_row['coll_inherits'])
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
deleted file mode 100644
index f2b637ee..00000000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_get_oid.py
+++ /dev/null
@@ -1,60 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2017, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import sys
-
-import jinja2
-
-from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
-
-DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-
-if sys.version_info[0] >= 3:
- long = int
-
-
-class TestTriggerGetOid(BaseTestGenerator):
- def runTest(self):
- """ When there are no permissions on the column, it returns an empty result """
- with test_utils.Database(self.server) as (connection, database_name):
- test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT pg_class.oid as table_id, "
- "pg_attribute.attnum as column_id "
- "FROM pg_class join pg_attribute on attrelid=pg_class.oid "
- "where pg_class.relname='test_table'"
- " and pg_attribute.attname = 'some_column'")
- table_id, column_id = cursor.fetchone()
-
- if connection.server_version < 90100:
- self.versions_to_test = ['default']
- else:
- self.versions_to_test = ['9.1_plus']
-
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "get_oid.sql")
-
- jinja2.filters.FILTERS['qtLiteral'] = lambda value: "NULL"
- template = file_as_template(template_file)
-
- sql = template.render(data={'name': None},
- tid=table_id
- )
-
- cursor = connection.cursor()
- cursor.execute(sql)
- fetch_result = cursor.fetchall()
- self.assertEqual(0, len(fetch_result))
-
-
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql.py
new file mode 100644
index 00000000..5ba560fd
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_acl_sql.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestColumnAclSql(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column ACL SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestColumnAclSql, self).__init__()
+ self.table_id = -1
+ self.column_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id, "
+ "pg_attribute.attnum AS column_id "
+ "FROM pg_class JOIN pg_attribute ON attrelid=pg_class.oid "
+ "WHERE pg_class.relname='test_table'"
+ " AND pg_attribute.attname = 'some_column'")
+ self.table_id, self.column_id = cursor.fetchone()
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "acl.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ tid=self.table_id,
+ clid=self.column_id
+ )
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(0, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "column", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql.py
new file mode 100644
index 00000000..ce6fa972
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_column_properties_sql.py
@@ -0,0 +1,52 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestColumnPropertiesSql(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Column Properties SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestColumnPropertiesSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
+
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "properties.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ tid=self.table_id
+ )
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('some_column', first_row['name'])
+ self.assertEqual('character varying', first_row['cltype'])
+ self.assertEqual(2, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "column", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql.py
new file mode 100644
index 00000000..de49852c
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_acl_sql.py
@@ -0,0 +1,54 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+from regression.python_test_utils.template_helper import file_as_template
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+
+
+class TestTablesAclSql(SQLTemplateTestBase):
+ scenarios = [
+ ("Test query returns the permissions when there are permissions set up"
+ " on the table", dict())
+ ]
+
+ def __init__(self):
+ super(TestTablesAclSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("GRANT SELECT ON test_table TO PUBLIC")
+ cursor = connection.cursor()
+ cursor.execute("SELECT oid FROM pg_class WHERE relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "acl.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ tid=self.table_id)
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ public_acls = list(filter(lambda acl: acl[1] == 'PUBLIC', fetch_result))
+ self.assertEqual(len(public_acls), 1)
+
+ new_acl_map = dict(zip(map(lambda column: column.name, descriptions), public_acls[0]))
+
+ self.assertEqual('PUBLIC', new_acl_map['grantee'])
+ self.assertEqual(self.server['username'], new_acl_map['grantor'])
+ self.assertEqual('relacl', new_acl_map['deftype'])
+ self.assertEqual(['r'], new_acl_map['privileges'])
+ self.assertEqual([False], new_acl_map['grantable'])
+ return public_acls
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "table", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql.py
new file mode 100644
index 00000000..1f344da3
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_node_sql.py
@@ -0,0 +1,55 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+import sys
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestTablesNodeSql(SQLTemplateTestBase):
+ scenarios = [
+ ("This scenario tests that all applicable sql template versions can "
+ "fetch table names", dict())
+ ]
+
+ def test_setup(self, connection, cursor):
+ pass
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "nodes.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id)
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ oid = first_row['oid']
+ name = first_row['name']
+ triggercount = first_row['triggercount']
+ has_enable_triggers = first_row['has_enable_triggers']
+
+ self.assertIsNotNone(long(oid))
+ self.assertEqual('test_table', name)
+ # triggercount is sometimes returned as a string for some reason
+ self.assertEqual(0, long(triggercount))
+ self.assertIsNotNone(long(has_enable_triggers))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "table", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py
new file mode 100644
index 00000000..861562b8
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_tables_properties_sql.py
@@ -0,0 +1,72 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+import sys
+
+from regression.python_test_utils.template_helper import file_as_template
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+
+
+if sys.version_info[0] >= 3:
+ long = int
+
+
+class TestTablesPropertiesSql(SQLTemplateTestBase):
+ scenarios = [
+ ("This scenario tests that all applicable sql template versions can "
+ "fetch some ddl", dict())
+ ]
+
+ def __init__(self):
+ super(TestTablesPropertiesSql, self).__init__()
+ self.database_id = -1
+ self.last_system_oid = -1
+ self.table_id = -1
+
+ def assertions(self, fetch_result, descriptions):
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('test_table', first_row['name'])
+ # triggercount is sometimes returned as a string for some reason
+ self.assertEqual(0, long(first_row['triggercount']))
+ self.assertEqual(None, first_row['typname'])
+ self.assertEqual([], first_row['coll_inherits'])
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "properties.sql")
+ template = file_as_template(template_file)
+ public_schema_id = 2200
+ sql = template.render(scid=public_schema_id,
+ did=self.database_id,
+ datlastsysoid=self.last_system_oid,
+ tid=self.table_id
+ )
+ return sql
+
+ def test_setup(self, connection, cursor):
+ cursor.execute(u"""
+ SELECT
+ db.oid as did, datlastsysoid
+ FROM
+ pg_database db
+ WHERE db.datname = '{0}'""".format(self.database_name)
+ )
+ self.database_id, self.last_system_oid = cursor.fetchone()
+
+ cursor.execute("SELECT oid FROM pg_class where relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "table", "sql", version, filename)
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql.py
new file mode 100644
index 00000000..3306fb7a
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_get_oid_sql.py
@@ -0,0 +1,52 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+import jinja2
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestTriggerGetOidSql(SQLTemplateTestBase):
+ scenarios = [
+ ('Test Trigger to retrieve OID SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestTriggerGetOidSql, self).__init__()
+ self.table_id = -1
+ self.column_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id, "
+ "pg_attribute.attnum AS column_id "
+ "FROM pg_class JOIN pg_attribute ON attrelid=pg_class.oid "
+ "WHERE pg_class.relname='test_table'"
+ " AND pg_attribute.attname = 'some_column'")
+ self.table_id, self.column_id = cursor.fetchone()
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "get_oid.sql")
+ jinja2.filters.FILTERS['qtLiteral'] = lambda value: "NULL"
+ template = file_as_template(template_file)
+
+ sql = template.render(data={'name': None},
+ tid=self.table_id
+ )
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(0, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "trigger", "sql", version, filename)
+
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql.py
new file mode 100644
index 00000000..8f328a60
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_trigger_nodes_sql.py
@@ -0,0 +1,43 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestTriggerNodesSql(SQLTemplateTestBase):
+ scenarios = [
+ ('Test Trigger Nodes SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestTriggerNodesSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "nodes.sql")
+ template = file_as_template(template_file)
+ sql = template.render(tid=self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(0, len(fetch_result))
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "trigger", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
new file mode 100644
index 00000000..e5bb8cb6
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
@@ -0,0 +1,45 @@
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
new file mode 100644
index 00000000..1281672f
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
@@ -0,0 +1,44 @@
+SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL THEN 'y'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ WHEN fs.oid IS NOT NULL THEN 'F'::text
+ WHEN fdw.oid IS NOT NULL THEN 'f'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.objid=cl.oid
+LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.objid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.objid=tg.oid
+LEFT JOIN pg_type ty ON dep.objid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.objid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.objid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.objid=la.oid
+LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
+LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
+LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
+{{where_clause}} AND
+classid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY classid, cl.relkind
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
new file mode 100644
index 00000000..aae5982e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
@@ -0,0 +1,42 @@
+SET LOCAL join_collapse_limit=8;
+SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
+ CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
+ WHEN tg.oid IS NOT NULL THEN 'T'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
+ WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
+ WHEN ns.oid IS NOT NULL THEN 'n'::text
+ WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN la.oid IS NOT NULL THEN 'l'::text
+ WHEN rw.oid IS NOT NULL THEN 'R'::text
+ WHEN co.oid IS NOT NULL THEN 'C'::text || contype
+ WHEN ad.oid IS NOT NULL THEN 'A'::text
+ ELSE ''
+ END AS type,
+ COALESCE(coc.relname, clrw.relname) AS ownertable,
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
+ END AS refname,
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+FROM pg_depend dep
+LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
+LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
+LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
+LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
+LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
+LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
+LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
+LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
+LEFT JOIN pg_class coc ON co.conrelid=coc.oid
+LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
+LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
+LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
+LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
+LEFT JOIN pg_language la ON dep.refobjid=la.oid
+LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
+LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+{{where_clause}} AND
+refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
+ ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
+ 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
+ORDER BY refclassid, cl.relkind
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
index e2ba3d6b..2fe2ef3e 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
@@ -1,59 +1,4 @@
-{% if fetch_dependencies %}
-SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
- CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
- WHEN tg.oid IS NOT NULL THEN 'T'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
- WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
- WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
- WHEN la.oid IS NOT NULL THEN 'l'::text
- WHEN rw.oid IS NOT NULL THEN 'R'::text
- WHEN co.oid IS NOT NULL THEN 'C'::text || contype
- WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
- ELSE ''
- END AS type,
- COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
- END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
-FROM pg_depend dep
-LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
-LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
-LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid
-LEFT JOIN pg_proc pr ON dep.refobjid=pr.oid
-LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid
-LEFT JOIN pg_trigger tg ON dep.refobjid=tg.oid
-LEFT JOIN pg_type ty ON dep.refobjid=ty.oid
-LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid
-LEFT JOIN pg_constraint co ON dep.refobjid=co.oid
-LEFT JOIN pg_class coc ON co.conrelid=coc.oid
-LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid
-LEFT JOIN pg_rewrite rw ON dep.refobjid=rw.oid
-LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
-LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
-LEFT JOIN pg_language la ON dep.refobjid=la.oid
-LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
-LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
-{{where_clause}} AND
-refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
- ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
- 'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY refclassid, cl.relkind
-{% endif %}
-
-{% if fetch_role_dependencies %}
-SELECT rolname AS refname, refclassid, deptype
-FROM pg_shdepend dep
-LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
-{{where_clause}} ORDER BY 1
-{% endif %}
-
-{% if fetch_dependents %}
+SET LOCAL join_collapse_limit=8;
SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')
WHEN tg.oid IS NOT NULL THEN 'T'::text
@@ -64,13 +9,11 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
WHEN ad.oid IS NOT NULL THEN 'A'::text
- WHEN fs.oid IS NOT NULL THEN 'F'::text
- WHEN fdw.oid IS NOT NULL THEN 'f'::text
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
- ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
+ ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
END AS refname,
COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
FROM pg_depend dep
@@ -91,11 +34,8 @@ LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
LEFT JOIN pg_language la ON dep.objid=la.oid
LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
-LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
-LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
{{where_clause}} AND
classid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY classid, cl.relkind
-{% endif %}
+ORDER BY classid, cl.relkind;
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
new file mode 100644
index 00000000..25fc3f85
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/role_dependencies.sql
@@ -0,0 +1,4 @@
+SELECT rolname AS refname, refclassid, deptype
+FROM pg_shdepend dep
+LEFT JOIN pg_roles r ON refclassid=1260 AND refobjid=r.oid
+{{where_clause}} ORDER BY 1
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql.py b/web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql.py
new file mode 100644
index 00000000..2a0235a2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_dependencies_sql.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestDependenciesSql(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestDependenciesSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "dependencies.sql")
+ template = file_as_template(template_file)
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('public', first_row["refname"])
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "depends", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql.py b/web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql.py
new file mode 100644
index 00000000..b82de6d9
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_dependents_sql.py
@@ -0,0 +1,51 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import os
+
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+
+
+class TestDependentsSql(SQLTemplateTestBase):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test dependencies SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestDependentsSql, self).__init__()
+ self.table_id = -1
+
+ def test_setup(self, connection, cursor):
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "dependents.sql")
+ template = file_as_template(template_file)
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('n', first_row["deptype"])
+ self.assertEqual('test_table', first_row["refname"])
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "depends", "sql", version, filename)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql.py b/web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql.py
new file mode 100644
index 00000000..827e44e1
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_role_dependencies_sql.py
@@ -0,0 +1,76 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+from pgadmin.browser.server_groups.servers.roles.tests.utils import create_role, delete_role
+from pgadmin.utils.route import BaseTestGenerator
+import os
+
+from regression.python_test_utils import test_utils
+from regression.python_test_utils.sql_template_test_base import SQLTemplateTestBase
+from regression.python_test_utils.template_helper import file_as_template
+from regression.python_test_utils.test_utils import create_database
+
+
+class TestRoleDependenciesSql(BaseTestGenerator):
+ scenarios = [
+ # Fetching default URL for schema node.
+ ('Test Role Dependencies SQL file', dict())
+ ]
+
+ def __init__(self):
+ super(TestRoleDependenciesSql, self).__init__()
+ self.table_id = -1
+
+ def setUp(self):
+ create_role(self.server, "testpgadmin")
+ self.server_with_modified_user = self.server.copy()
+ self.server_with_modified_user['username'] = "testpgadmin"
+
+ def runTest(self):
+ if hasattr(self, "ignore_test"):
+ return
+
+ with test_utils.Database(self.server) as (connection, database_name):
+ test_utils.create_table(self.server_with_modified_user, database_name, "test_new_role_table")
+ cursor = connection.cursor()
+ cursor.execute("SELECT pg_class.oid AS table_id "
+ "FROM pg_class "
+ "WHERE pg_class.relname='test_new_role_table'")
+ self.table_id = cursor.fetchone()[0]
+
+ sql = self.generate_sql('default')
+ cursor.execute(sql)
+
+ fetch_result = cursor.fetchall()
+ self.assertions(fetch_result, cursor.description)
+
+ def tearDown(self):
+ with test_utils.Database(self.server) as (connection, database_name):
+ cursor = connection.cursor()
+ cursor.execute("DROP ROLE testpgadmin")
+ connection.commit()
+
+ def generate_sql(self, version):
+ template_file = self.get_template_file(version, "role_dependencies.sql")
+ template = file_as_template(template_file)
+ sql = template.render(where_clause="WHERE dep.objid=%s::oid" % self.table_id)
+
+ return sql
+
+ def assertions(self, fetch_result, descriptions):
+ self.assertEqual(1, len(fetch_result))
+
+ first_row = {}
+ for index, description in enumerate(descriptions):
+ first_row[description.name] = fetch_result[0][index]
+
+ self.assertEqual('o', first_row["deptype"])
+
+ @staticmethod
+ def get_template_file(version, filename):
+ return os.path.join(os.path.dirname(__file__), "..", "templates", "depends", "sql", version, filename)
diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
index d2899875..708bfdfb 100644
--- a/web/pgadmin/browser/utils.py
+++ b/web/pgadmin/browser/utils.py
@@ -353,15 +353,15 @@ class PGChildNodeView(NodeView):
else:
where_clause = where
- query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependencies=True, where_clause=where_clause)
+ query = render_template("/".join([sql_path, 'dependencies.sql']),
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependencies = self.__fetch_dependency(conn, query)
# fetch role dependencies
if where_clause.find('subid') < 0:
- sql = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_role_dependencies=True, where_clause=where_clause)
+ sql = render_template("/".join([sql_path, 'role_dependencies.sql']),
+ where_clause=where_clause)
status, result = conn.execute_dict(sql)
if not status:
@@ -402,7 +402,7 @@ class PGChildNodeView(NodeView):
where_clause = where
query = render_template("/".join([sql_path, 'dependents.sql']),
- fetch_dependents=True, where_clause=where_clause)
+ where_clause=where_clause)
# fetch the dependency for the selected object
dependents = self.__fetch_dependency(conn, query)
diff --git a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
index 223579ee..338e5f71 100644
--- a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
+++ b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
@@ -1,3 +1,12 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
import pyperclip
import time
@@ -37,7 +46,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
self.page.find_by_partial_link_text("Query Tool").click()
self.page.click_tab('Query-1')
time.sleep(5)
- ActionChains(self.page.driver).send_keys("SELECT * FROM test_table").perform()
+ ActionChains(self.page.driver).send_keys("SELECT * FROM test_table ORDER BY some_column").perform()
self.page.driver.switch_to_frame(self.page.driver.find_element_by_tag_name("iframe"))
self.page.find_by_id("btn-flash").click()
diff --git a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
index 8b018fed..17bc7bf5 100644
--- a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
+++ b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py
@@ -16,10 +16,14 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest):
"""Tests to check if Debugger is vulnerable to XSS."""
scenarios = [
- ("Test table DDL generation", dict())
+ ("Tests to check if Debugger is vulnerable to XSS", dict())
]
def before(self):
+ with test_utils.Database(self.server) as (connection, _):
+ if connection.server_version < 90100:
+ self.skipTest("Functions tree node is not present in pgAdmin below PG v9.1")
+
# Some test function is needed for debugger
test_utils.create_debug_function(self.server, "postgres",
"test_function")
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py b/web/regression/python_test_utils/sql_template_test_base.py
similarity index 59%
rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
rename to web/regression/python_test_utils/sql_template_test_base.py
index b23bf60a..8009e31e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/tests/test_trigger_nodes.py
+++ b/web/regression/python_test_utils/sql_template_test_base.py
@@ -7,45 +7,53 @@
#
##########################################################################
-import os
-import sys
-
+from pgadmin.utils.route import BaseTestGenerator
+from regression.python_test_utils import test_utils
from pgadmin.utils.driver import DriverRegistry
-from regression.python_test_utils.template_helper import file_as_template
DriverRegistry.load_drivers()
-from pgadmin.utils.route import BaseTestGenerator
-from regression.python_test_utils import test_utils
-if sys.version_info[0] >= 3:
- long = int
+class SQLTemplateTestBase(BaseTestGenerator):
+ scenarios = [
+ ("parent test class", dict(ignore_test=True))
+ ]
+
+ def __init__(self):
+ super(SQLTemplateTestBase, self).__init__()
+ self.database_name = -1
+ self.versions_to_test = -1
+
+ def test_setup(self, connection, cursor):
+ pass
+
+ def generate_sql(self, version):
+ pass
+
+ def assertions(self, fetch_result, descriptions):
+ pass
-class TestTriggerNodes(BaseTestGenerator):
def runTest(self):
- """ When there are no triggers, it returns an empty result """
+ if hasattr(self, "ignore_test"):
+ return
+
with test_utils.Database(self.server) as (connection, database_name):
test_utils.create_table(self.server, database_name, "test_table")
-
- cursor = connection.cursor()
- cursor.execute("SELECT pg_class.oid AS table_id "
- "FROM pg_class "
- "WHERE pg_class.relname='test_table'")
- table_id = cursor.fetchone()[0]
+ self.database_name = database_name
if connection.server_version < 90100:
self.versions_to_test = ['default']
else:
self.versions_to_test = ['9.1_plus']
- for version in self.versions_to_test:
- template_file = os.path.join(os.path.dirname(__file__), "..", version, "nodes.sql")
-
- template = file_as_template(template_file)
+ cursor = connection.cursor()
+ self.test_setup(connection, cursor)
- sql = template.render(tid=table_id)
+ for version in self.versions_to_test:
+ sql = self.generate_sql(version)
cursor = connection.cursor()
cursor.execute(sql)
fetch_result = cursor.fetchall()
- self.assertEqual(0, len(fetch_result))
+
+ self.assertions(fetch_result, cursor.description)
--
2.12.0
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-11 06:11 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-11 06:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-11 07:20 ` Re: [patch] Dependents and Dependencies in GreenPlum Khushboo Vashi <[email protected]>
2017-05-11 11:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-12 17:53 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
@ 2017-05-14 08:52 ` Akshay Joshi <[email protected]>
2017-05-15 00:49 ` Re: [patch] Dependents and Dependencies in GreenPlum Matthew Kleiman <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Akshay Joshi @ 2017-05-14 08:52 UTC (permalink / raw)
To: Joao Pedro De Almeida Pereira <[email protected]>; +Cc: pgadmin-hackers; George Gelashvili <[email protected]>
Hi Joao
On Fri, May 12, 2017 at 11:23 PM, Joao Pedro De Almeida Pereira <
[email protected]> wrote:
> Hello Akshay,
>
> You can find attached a new version of the patch that changes the test in
> question.
> This new version instead of requiring a creation of a new Role now does
> the following:
> 1 - Creates a new Role
> 2 - Creates a table with that Role
> 3 - Checks for dependencies
>
Test case still failing on my machine because when we create new Role it
is without password and when we try to create table with that role first we
will try to connect the database using that new role with
servers['db_password'] which is wrong. I have modified setup function of "
*test_role_dependencies_sql.py*" and it works, we can create new role using
database server's password
Old setup function:
*def *setUp(self):
create_role(self.server, *"testpgadmin"*)
self.server_with_modified_user = self.server.copy()
self.server_with_modified_user[*'username'*] = *"testpgadmin"*
Modified setup function:
def setUp(self):
with test_utils.Database(self.server) as (connection, database_name):
cursor = connection.cursor()
try:
cursor.execute(
"CREATE ROLE testpgadmin LOGIN PASSWORD '%s'"
% self.server['db_password'])
except Exception as exception:
print(exception)
connection.commit()
self.server_with_modified_user = self.server.copy()
self.server_with_modified_user['username'] = "testpgadmin"
If the above logic looks good to you then I'll commit the code.
>
> Thanks
> Joao & George
>
> On Thu, May 11, 2017 at 7:33 AM, Joao Pedro De Almeida Pereira <
> [email protected]> wrote:
>
>> Hello all,
>> This test is trying to check if the sql to retrieve the role dependencies
>> of a object in the database is correct. Using a different user to connect
>> to the database and create tables there is no need for extra setup because
>> the role depedencies table entry is added automatically. Also we talked
>> with some internal users and they told us they always used a different user
>> to connect to the database with pgadmin.
>>
>> After your comments we realize that the test need to have a different
>> setup in order to become more readable and resilient. What do we need to do
>> in the test setup to ensure an entry is added to the role dependency table?
>>
>> Also the test need to be a little bit more resilient to work
>> independently of the user that is used on the test.
>>
>> Thanks
>> Joao
>>
>> On Thu, May 11, 2017, 3:20 AM Khushboo Vashi <
>> [email protected]> wrote:
>>
>>> On Thu, May 11, 2017 at 12:03 PM, Dave Page <[email protected]> wrote:
>>>
>>>>
>>>>
>>>> On 11 May 2017, at 07:11, Akshay Joshi <[email protected]>
>>>> wrote:
>>>>
>>>> Hi Sarah
>>>>
>>>> On Thu, May 11, 2017 at 2:30 AM, Sarah McAlear <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi Ashkay!
>>>>>
>>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed
>>>>>> with below error:
>>>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>>>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>>
>>>>>
>>>>> We experienced a similar problem when we started developing this
>>>>> patch. We noticed that we were connecting to the database with the super
>>>>> user (the db owner user), which did not create the role we are expecting
>>>>> when a table is created. To ensure that this role is created, we had to
>>>>> create a new user and use it to execute all the tests. After we made this
>>>>> change, the tests passed.
>>>>>
>>>>> Can you try to create a new user and use it to execute your tests?
>>>>>
>>>>
>>>> I did that and it works. I have created new user 'test' with
>>>> superuser privileges and update parameter db_username="test" in
>>>> test_config.json file. But still I am unable to understand why it doesn't
>>>> work with 'postgres' (default) user?
>>>>
>>>>
>>>> Agreed. That suggests something fishy is going on that should be
>>>> understood.
>>>>
>>>>
>>> We don't check role dependencies for every object. As per the code, the
>>> role dependencies are executed for columns not for the table itself.
>>> And in the test cases, the table object is trying to execute the role
>>> dependencies, so I think this test case is not correct.
>>>
>>>>
>>>>> Thanks,
>>>>> João & Sarah
>>>>>
>>>>> On Wed, May 10, 2017 at 1:56 PM, Akshay Joshi <
>>>>> [email protected]> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
>>>>>>
>>>>>> Hi Akshay!
>>>>>>
>>>>>> Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all our
>>>>>> tests pass.
>>>>>>
>>>>>>
>>>>>> On both 9.6 and 10.0. Query returned 0 rows which is compared
>>>>>> against 1 in assert statement.
>>>>>>
>>>>>>
>>>>>> Thanks!
>>>>>> João & Sarah
>>>>>>
>>>>>> On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hi Sarah
>>>>>>>
>>>>>>> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi Akshay!
>>>>>>>>
>>>>>>>>
>>>>>>>>> Some test file names ended with "*_sql_template.py*" do we need
>>>>>>>>> to add that string ?
>>>>>>>>
>>>>>>>> we added this suffix after moving the tests up a level to
>>>>>>>> tables/tests to clarify what subject they applied to. we changed the suffix
>>>>>>>> to "_sql.py"
>>>>>>>>
>>>>>>>> - Files "test_column_acl_sql_template.py" and "
>>>>>>>>> test_column_properties_sql_template.py" should be moved from
>>>>>>>>> tables->tests to tables->column->tests. As it's related to column.
>>>>>>>>> - Files "test_trigger_get_oid_sql_template.py" and "
>>>>>>>>> test_trigger_nodes_sql_template.py" should be moved from
>>>>>>>>> tables->tests to tables->triggers->tests. As its related to triggers.
>>>>>>>>
>>>>>>>> these tests are related to the sql files in
>>>>>>>> tables/templates/column, not tables/column, so moving them into
>>>>>>>> tables/column would be more confusing.
>>>>>>>>
>>>>>>>> Following test cases are failing
>>>>>>>>
>>>>>>>> Thank you, fixed, see new patch. Can you confirm that
>>>>>>>> TestTablesNodeSql doesn't fail in your environment?
>>>>>>>>
>>>>>>>
>>>>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql
>>>>>>> failed with below error:
>>>>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>>>>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>>>>
>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> George & Sarah
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> *Akshay Joshi*
>>>>>>> *Principal Software Engineer *
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Akshay Joshi*
>>>> *Principal Software Engineer *
>>>>
>>>>
>>>>
>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>
>>>>
>
--
*Akshay Joshi*
*Principal Software Engineer *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-11 06:11 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-11 06:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-11 07:20 ` Re: [patch] Dependents and Dependencies in GreenPlum Khushboo Vashi <[email protected]>
2017-05-11 11:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-12 17:53 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-14 08:52 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
@ 2017-05-15 00:49 ` Matthew Kleiman <[email protected]>
2017-05-15 05:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
0 siblings, 1 reply; 27+ messages in thread
From: Matthew Kleiman @ 2017-05-15 00:49 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: Joao Pedro De Almeida Pereira <[email protected]>; pgadmin-hackers; George Gelashvili <[email protected]>
Hi Akshay
I really appreciate you taking a look at this on a Sunday!
I am not able to get access to my work computer to run your changes
directly. From what you are saying, though, it sounds like a reasonable
change. If this change is passing in your environment, I say go ahead and
make the change to the patch and commit.
Thanks again for helping us get this into the release.
Best,
Matt
On Sun, May 14, 2017 at 4:52 AM, Akshay Joshi <[email protected]
> wrote:
> Hi Joao
>
> On Fri, May 12, 2017 at 11:23 PM, Joao Pedro De Almeida Pereira <
> [email protected]> wrote:
>
>> Hello Akshay,
>>
>> You can find attached a new version of the patch that changes the test in
>> question.
>> This new version instead of requiring a creation of a new Role now does
>> the following:
>> 1 - Creates a new Role
>> 2 - Creates a table with that Role
>> 3 - Checks for dependencies
>>
>
> Test case still failing on my machine because when we create new Role
> it is without password and when we try to create table with that role first
> we will try to connect the database using that new role with
> servers['db_password'] which is wrong. I have modified setup function of "
> *test_role_dependencies_sql.py*" and it works, we can create new role
> using database server's password
>
> Old setup function:
> *def *setUp(self):
>
> create_role(self.server, *"testpgadmin"*)
> self.server_with_modified_user = self.server.copy()
> self.server_with_modified_user[*'username'*] = *"testpgadmin"*
>
>
> Modified setup function:
>
>
> def setUp(self):
>
> with test_utils.Database(self.server) as (connection, database_name):
> cursor = connection.cursor()
> try:
> cursor.execute(
> "CREATE ROLE testpgadmin LOGIN PASSWORD '%s'"
> % self.server['db_password'])
> except Exception as exception:
> print(exception)
> connection.commit()
>
> self.server_with_modified_user = self.server.copy()
> self.server_with_modified_user['username'] = "testpgadmin"
>
>
> If the above logic looks good to you then I'll commit the code.
>
>>
>> Thanks
>> Joao & George
>>
>> On Thu, May 11, 2017 at 7:33 AM, Joao Pedro De Almeida Pereira <
>> [email protected]> wrote:
>>
>>> Hello all,
>>> This test is trying to check if the sql to retrieve the role
>>> dependencies of a object in the database is correct. Using a different user
>>> to connect to the database and create tables there is no need for extra
>>> setup because the role depedencies table entry is added automatically. Also
>>> we talked with some internal users and they told us they always used a
>>> different user to connect to the database with pgadmin.
>>>
>>> After your comments we realize that the test need to have a different
>>> setup in order to become more readable and resilient. What do we need to do
>>> in the test setup to ensure an entry is added to the role dependency table?
>>>
>>> Also the test need to be a little bit more resilient to work
>>> independently of the user that is used on the test.
>>>
>>> Thanks
>>> Joao
>>>
>>> On Thu, May 11, 2017, 3:20 AM Khushboo Vashi <
>>> [email protected]> wrote:
>>>
>>>> On Thu, May 11, 2017 at 12:03 PM, Dave Page <[email protected]> wrote:
>>>>
>>>>>
>>>>>
>>>>> On 11 May 2017, at 07:11, Akshay Joshi <[email protected]>
>>>>> wrote:
>>>>>
>>>>> Hi Sarah
>>>>>
>>>>> On Thu, May 11, 2017 at 2:30 AM, Sarah McAlear <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hi Ashkay!
>>>>>>
>>>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed
>>>>>>> with below error:
>>>>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>>>>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>>>
>>>>>>
>>>>>> We experienced a similar problem when we started developing this
>>>>>> patch. We noticed that we were connecting to the database with the super
>>>>>> user (the db owner user), which did not create the role we are expecting
>>>>>> when a table is created. To ensure that this role is created, we had to
>>>>>> create a new user and use it to execute all the tests. After we made this
>>>>>> change, the tests passed.
>>>>>>
>>>>>> Can you try to create a new user and use it to execute your tests?
>>>>>>
>>>>>
>>>>> I did that and it works. I have created new user 'test' with
>>>>> superuser privileges and update parameter db_username="test" in
>>>>> test_config.json file. But still I am unable to understand why it doesn't
>>>>> work with 'postgres' (default) user?
>>>>>
>>>>>
>>>>> Agreed. That suggests something fishy is going on that should be
>>>>> understood.
>>>>>
>>>>>
>>>> We don't check role dependencies for every object. As per the code, the
>>>> role dependencies are executed for columns not for the table itself.
>>>> And in the test cases, the table object is trying to execute the role
>>>> dependencies, so I think this test case is not correct.
>>>>
>>>>>
>>>>>> Thanks,
>>>>>> João & Sarah
>>>>>>
>>>>>> On Wed, May 10, 2017 at 1:56 PM, Akshay Joshi <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
>>>>>>>
>>>>>>> Hi Akshay!
>>>>>>>
>>>>>>> Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all
>>>>>>> our tests pass.
>>>>>>>
>>>>>>>
>>>>>>> On both 9.6 and 10.0. Query returned 0 rows which is compared
>>>>>>> against 1 in assert statement.
>>>>>>>
>>>>>>>
>>>>>>> Thanks!
>>>>>>> João & Sarah
>>>>>>>
>>>>>>> On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Hi Sarah
>>>>>>>>
>>>>>>>> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi Akshay!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Some test file names ended with "*_sql_template.py*" do we need
>>>>>>>>>> to add that string ?
>>>>>>>>>
>>>>>>>>> we added this suffix after moving the tests up a level to
>>>>>>>>> tables/tests to clarify what subject they applied to. we changed the suffix
>>>>>>>>> to "_sql.py"
>>>>>>>>>
>>>>>>>>> - Files "test_column_acl_sql_template.py" and "
>>>>>>>>>> test_column_properties_sql_template.py" should be moved from
>>>>>>>>>> tables->tests to tables->column->tests. As it's related to column.
>>>>>>>>>> - Files "test_trigger_get_oid_sql_template.py" and "
>>>>>>>>>> test_trigger_nodes_sql_template.py" should be moved from
>>>>>>>>>> tables->tests to tables->triggers->tests. As its related to triggers.
>>>>>>>>>
>>>>>>>>> these tests are related to the sql files in
>>>>>>>>> tables/templates/column, not tables/column, so moving them into
>>>>>>>>> tables/column would be more confusing.
>>>>>>>>>
>>>>>>>>> Following test cases are failing
>>>>>>>>>
>>>>>>>>> Thank you, fixed, see new patch. Can you confirm that
>>>>>>>>> TestTablesNodeSql doesn't fail in your environment?
>>>>>>>>>
>>>>>>>>
>>>>>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql
>>>>>>>> failed with below error:
>>>>>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>>>>>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>>>>>
>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> George & Sarah
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Akshay Joshi*
>>>>>>>> *Principal Software Engineer *
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>>>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Akshay Joshi*
>>>>> *Principal Software Engineer *
>>>>>
>>>>>
>>>>>
>>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>>
>>>>>
>>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91 976-788-8246
> <+91%2097678%2088246>*
>
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: [patch] Dependents and Dependencies in GreenPlum
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-04-26 05:26 ` Re: [patch] Dependents and Dependencies in GreenPlum Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Re: [patch] Dependents and Dependencies in GreenPlum Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:16 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 08:50 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-08 16:14 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Re: [patch] Dependents and Dependencies in GreenPlum Sarah McAlear <[email protected]>
2017-05-11 06:11 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-11 06:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Dave Page <[email protected]>
2017-05-11 07:20 ` Re: [patch] Dependents and Dependencies in GreenPlum Khushboo Vashi <[email protected]>
2017-05-11 11:33 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-12 17:53 ` Re: [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-05-14 08:52 ` Re: [patch] Dependents and Dependencies in GreenPlum Akshay Joshi <[email protected]>
2017-05-15 00:49 ` Re: [patch] Dependents and Dependencies in GreenPlum Matthew Kleiman <[email protected]>
@ 2017-05-15 05:14 ` Akshay Joshi <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Akshay Joshi @ 2017-05-15 05:14 UTC (permalink / raw)
To: Matthew Kleiman <[email protected]>; +Cc: Joao Pedro De Almeida Pereira <[email protected]>; pgadmin-hackers; George Gelashvili <[email protected]>
Thanks patch applied.
On Mon, May 15, 2017 at 6:19 AM, Matthew Kleiman <[email protected]>
wrote:
> Hi Akshay
>
> I really appreciate you taking a look at this on a Sunday!
> I am not able to get access to my work computer to run your changes
> directly. From what you are saying, though, it sounds like a reasonable
> change. If this change is passing in your environment, I say go ahead and
> make the change to the patch and commit.
>
> Thanks again for helping us get this into the release.
>
> Best,
> Matt
>
> On Sun, May 14, 2017 at 4:52 AM, Akshay Joshi <
> [email protected]> wrote:
>
>> Hi Joao
>>
>> On Fri, May 12, 2017 at 11:23 PM, Joao Pedro De Almeida Pereira <
>> [email protected]> wrote:
>>
>>> Hello Akshay,
>>>
>>> You can find attached a new version of the patch that changes the test
>>> in question.
>>> This new version instead of requiring a creation of a new Role now does
>>> the following:
>>> 1 - Creates a new Role
>>> 2 - Creates a table with that Role
>>> 3 - Checks for dependencies
>>>
>>
>> Test case still failing on my machine because when we create new Role
>> it is without password and when we try to create table with that role first
>> we will try to connect the database using that new role with
>> servers['db_password'] which is wrong. I have modified setup function of "
>> *test_role_dependencies_sql.py*" and it works, we can create new role
>> using database server's password
>>
>> Old setup function:
>> *def *setUp(self):
>>
>> create_role(self.server, *"testpgadmin"*)
>> self.server_with_modified_user = self.server.copy()
>> self.server_with_modified_user[*'username'*] = *"testpgadmin"*
>>
>>
>> Modified setup function:
>>
>>
>> def setUp(self):
>>
>> with test_utils.Database(self.server) as (connection, database_name):
>> cursor = connection.cursor()
>> try:
>> cursor.execute(
>> "CREATE ROLE testpgadmin LOGIN PASSWORD '%s'"
>> % self.server['db_password'])
>> except Exception as exception:
>> print(exception)
>> connection.commit()
>>
>> self.server_with_modified_user = self.server.copy()
>> self.server_with_modified_user['username'] = "testpgadmin"
>>
>>
>> If the above logic looks good to you then I'll commit the code.
>>
>>>
>>> Thanks
>>> Joao & George
>>>
>>> On Thu, May 11, 2017 at 7:33 AM, Joao Pedro De Almeida Pereira <
>>> [email protected]> wrote:
>>>
>>>> Hello all,
>>>> This test is trying to check if the sql to retrieve the role
>>>> dependencies of a object in the database is correct. Using a different user
>>>> to connect to the database and create tables there is no need for extra
>>>> setup because the role depedencies table entry is added automatically. Also
>>>> we talked with some internal users and they told us they always used a
>>>> different user to connect to the database with pgadmin.
>>>>
>>>> After your comments we realize that the test need to have a different
>>>> setup in order to become more readable and resilient. What do we need to do
>>>> in the test setup to ensure an entry is added to the role dependency table?
>>>>
>>>> Also the test need to be a little bit more resilient to work
>>>> independently of the user that is used on the test.
>>>>
>>>> Thanks
>>>> Joao
>>>>
>>>> On Thu, May 11, 2017, 3:20 AM Khushboo Vashi <
>>>> [email protected]> wrote:
>>>>
>>>>> On Thu, May 11, 2017 at 12:03 PM, Dave Page <[email protected]> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On 11 May 2017, at 07:11, Akshay Joshi <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>> Hi Sarah
>>>>>>
>>>>>> On Thu, May 11, 2017 at 2:30 AM, Sarah McAlear <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Ashkay!
>>>>>>>
>>>>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql failed
>>>>>>>> with below error:
>>>>>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions\n
>>>>>>>> self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>>>>
>>>>>>>
>>>>>>> We experienced a similar problem when we started developing this
>>>>>>> patch. We noticed that we were connecting to the database with the super
>>>>>>> user (the db owner user), which did not create the role we are expecting
>>>>>>> when a table is created. To ensure that this role is created, we had to
>>>>>>> create a new user and use it to execute all the tests. After we made this
>>>>>>> change, the tests passed.
>>>>>>>
>>>>>>> Can you try to create a new user and use it to execute your tests?
>>>>>>>
>>>>>>
>>>>>> I did that and it works. I have created new user 'test' with
>>>>>> superuser privileges and update parameter db_username="test" in
>>>>>> test_config.json file. But still I am unable to understand why it doesn't
>>>>>> work with 'postgres' (default) user?
>>>>>>
>>>>>>
>>>>>> Agreed. That suggests something fishy is going on that should be
>>>>>> understood.
>>>>>>
>>>>>>
>>>>> We don't check role dependencies for every object. As per the code,
>>>>> the role dependencies are executed for columns not for the table itself.
>>>>> And in the test cases, the table object is trying to execute the role
>>>>> dependencies, so I think this test case is not correct.
>>>>>
>>>>>>
>>>>>>> Thanks,
>>>>>>> João & Sarah
>>>>>>>
>>>>>>> On Wed, May 10, 2017 at 1:56 PM, Akshay Joshi <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On May 10, 2017 19:07, "Sarah McAlear" <[email protected]> wrote:
>>>>>>>>
>>>>>>>> Hi Akshay!
>>>>>>>>
>>>>>>>> Does this error occur on 9.6 or 10.0? We tested it in 9.6 and all
>>>>>>>> our tests pass.
>>>>>>>>
>>>>>>>>
>>>>>>>> On both 9.6 and 10.0. Query returned 0 rows which is compared
>>>>>>>> against 1 in assert statement.
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>> João & Sarah
>>>>>>>>
>>>>>>>> On Wed, May 10, 2017 at 2:29 AM, Akshay Joshi <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> Hi Sarah
>>>>>>>>>
>>>>>>>>> On Tue, May 9, 2017 at 9:03 PM, Sarah McAlear <[email protected]
>>>>>>>>> > wrote:
>>>>>>>>>
>>>>>>>>>> Hi Akshay!
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Some test file names ended with "*_sql_template.py*" do we need
>>>>>>>>>>> to add that string ?
>>>>>>>>>>
>>>>>>>>>> we added this suffix after moving the tests up a level to
>>>>>>>>>> tables/tests to clarify what subject they applied to. we changed the suffix
>>>>>>>>>> to "_sql.py"
>>>>>>>>>>
>>>>>>>>>> - Files "test_column_acl_sql_template.py" and "
>>>>>>>>>>> test_column_properties_sql_template.py" should be moved from
>>>>>>>>>>> tables->tests to tables->column->tests. As it's related to column.
>>>>>>>>>>> - Files "test_trigger_get_oid_sql_template.py" and "
>>>>>>>>>>> test_trigger_nodes_sql_template.py" should be moved from
>>>>>>>>>>> tables->tests to tables->triggers->tests. As its related to triggers.
>>>>>>>>>>
>>>>>>>>>> these tests are related to the sql files in
>>>>>>>>>> tables/templates/column, not tables/column, so moving them into
>>>>>>>>>> tables/column would be more confusing.
>>>>>>>>>>
>>>>>>>>>> Following test cases are failing
>>>>>>>>>>
>>>>>>>>>> Thank you, fixed, see new patch. Can you confirm that
>>>>>>>>>> TestTablesNodeSql doesn't fail in your environment?
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> TestTablesNodeSql hasn't failed but TestRoleDependenciesSql
>>>>>>>>> failed with below error:
>>>>>>>>> .....\test_role_dependencies_sql.py\", line 41, in assertions
>>>>>>>>> \n self.assertEqual(1, len(fetch_result))\nAssertionError: 1 != 0
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> George & Sarah
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> *Akshay Joshi*
>>>>>>>>> *Principal Software Engineer *
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>>>>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Akshay Joshi*
>>>>>> *Principal Software Engineer *
>>>>>>
>>>>>>
>>>>>>
>>>>>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91
>>>>>> 976-788-8246 <+91%2097678%2088246>*
>>>>>>
>>>>>>
>>>
>>
>>
>> --
>> *Akshay Joshi*
>> *Principal Software Engineer *
>>
>>
>>
>> *Phone: +91 20-3058-9517 <+91%2020%203058%209517>Mobile: +91 976-788-8246
>> <+91%2097678%2088246>*
>>
>
>
--
*Akshay Joshi*
*Principal Software Engineer *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 27+ messages in thread
end of thread, other threads:[~2017-05-15 05:14 UTC | newest]
Thread overview: 27+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21 19:42 [patch] Dependents and Dependencies in GreenPlum Joao Pedro De Almeida Pereira <[email protected]>
2017-04-24 11:13 ` Dave Page <[email protected]>
2017-04-26 05:26 ` Ashesh Vashi <[email protected]>
2017-04-26 15:22 ` Joao Pedro De Almeida Pereira <[email protected]>
2017-04-27 14:37 ` Joao Pedro De Almeida Pereira <[email protected]>
2017-05-02 21:17 ` Sarah McAlear <[email protected]>
2017-05-04 11:51 ` Robert Eckhardt <[email protected]>
2017-05-05 12:18 ` Dave Page <[email protected]>
2017-05-08 08:16 ` Dave Page <[email protected]>
2017-05-08 08:50 ` Akshay Joshi <[email protected]>
2017-05-08 11:24 ` Akshay Joshi <[email protected]>
2017-05-08 11:28 ` Dave Page <[email protected]>
2017-05-08 16:14 ` Sarah McAlear <[email protected]>
2017-05-09 10:01 ` Akshay Joshi <[email protected]>
2017-05-09 15:33 ` Sarah McAlear <[email protected]>
2017-05-10 06:29 ` Akshay Joshi <[email protected]>
2017-05-10 13:37 ` Sarah McAlear <[email protected]>
2017-05-10 17:56 ` Akshay Joshi <[email protected]>
2017-05-10 21:00 ` Sarah McAlear <[email protected]>
2017-05-11 06:11 ` Akshay Joshi <[email protected]>
2017-05-11 06:33 ` Dave Page <[email protected]>
2017-05-11 07:20 ` Khushboo Vashi <[email protected]>
2017-05-11 11:33 ` Joao Pedro De Almeida Pereira <[email protected]>
2017-05-12 17:53 ` Joao Pedro De Almeida Pereira <[email protected]>
2017-05-14 08:52 ` Akshay Joshi <[email protected]>
2017-05-15 00:49 ` Matthew Kleiman <[email protected]>
2017-05-15 05:14 ` 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