mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed reverse engineering SQL where parenthesis is not properly arranged for View/MView definition. Fixes #5830
This commit is contained in:
parent
3489f94ca7
commit
b0475566ca
@ -20,4 +20,5 @@ Bug fixes
|
||||
| `Issue #5417 <https://redmine.postgresql.org/issues/5417>`_ - Fixed and improve API test cases for the schema diff tool.
|
||||
| `Issue #5802 <https://redmine.postgresql.org/issues/5802>`_ - Remove maximum length on the password field in the server dialog.
|
||||
| `Issue #5807 <https://redmine.postgresql.org/issues/5807>`_ - Fixed an issue where a column is renamed and then removed, then the drop SQL query takes the wrong column name.
|
||||
| `Issue #5830 <https://redmine.postgresql.org/issues/5830>`_ - Fixed reverse engineering SQL where parenthesis is not properly arranged for View/MView definition.
|
||||
| `Issue #5839 <https://redmine.postgresql.org/issues/5839>`_ - Ensure that multiple extensions can be dropped from the properties tab.
|
@ -15,7 +15,7 @@ SELECT
|
||||
nsp.nspname as schema,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
description AS comment,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
{# ============= Checks if it is system view ================ #}
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
|
@ -15,7 +15,7 @@ SELECT
|
||||
nsp.nspname as schema,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
description AS comment,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
{# ============= Checks if it is system view ================ #}
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
|
@ -15,7 +15,7 @@ SELECT
|
||||
nsp.nspname as schema,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
description AS comment,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
{# ============= Checks if it is system view ================ #}
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
|
@ -8,7 +8,7 @@ SELECT
|
||||
description AS comment,
|
||||
c.reltablespace AS spcoid,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
array_to_string(c.relacl::text[], ', ') AS acl,
|
||||
{#=============Checks if it is system view================#}
|
||||
{% if vid and datlastsysoid %}
|
||||
|
@ -8,7 +8,7 @@ SELECT
|
||||
description AS comment,
|
||||
c.reltablespace AS spcoid,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
array_to_string(c.relacl::text[], ', ') AS acl,
|
||||
{#=============Checks if it is system view================#}
|
||||
{% if vid and datlastsysoid %}
|
||||
|
@ -8,7 +8,7 @@ SELECT
|
||||
(CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
description As comment,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
nsp.nspname AS schema,
|
||||
array_to_string(c.relacl::text[], ', ') AS acl,
|
||||
{#=============Checks if it is system view================#}
|
||||
|
@ -11,7 +11,7 @@ SELECT
|
||||
c.relispopulated AS ispopulated,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
array_to_string(c.relacl::text[], ', ') AS acl,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
{# ===== Checks if it is system view ===== #}
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
|
@ -12,7 +12,7 @@ SELECT
|
||||
c.relispopulated AS ispopulated,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
array_to_string(c.relacl::text[], ', ') AS acl,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
{# ===== Checks if it is system view ===== #}
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
|
@ -11,7 +11,7 @@ SELECT
|
||||
c.relispopulated AS ispopulated,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
array_to_string(c.relacl::text[], ', ') AS acl,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
{# ===== Checks if it is system view ===== #}
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
|
@ -7,7 +7,7 @@ SELECT
|
||||
(CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
description As comment,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
nsp.nspname AS schema,
|
||||
array_to_string(c.relacl::text[], ', ') AS acl,
|
||||
{#=============Checks if it is system view================#}
|
||||
|
@ -11,7 +11,7 @@ SELECT
|
||||
c.relispopulated AS ispopulated,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
array_to_string(c.relacl::text[], ', ') AS acl,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
{# ===== Checks if it is system view ===== #}
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
|
@ -12,7 +12,7 @@ SELECT
|
||||
c.relispopulated AS ispopulated,
|
||||
pg_get_userbyid(c.relowner) AS owner,
|
||||
array_to_string(c.relacl::text[], ', ') AS acl,
|
||||
pg_get_viewdef(c.oid, true) AS definition,
|
||||
pg_get_viewdef(c.oid) AS definition,
|
||||
{# ===== Checks if it is system view ===== #}
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
|
@ -8,6 +8,7 @@
|
||||
##########################################################################
|
||||
|
||||
import uuid
|
||||
import json
|
||||
|
||||
from pgadmin.browser.server_groups.servers.databases.schemas.tests import \
|
||||
utils as schema_utils
|
||||
@ -27,15 +28,29 @@ class ViewsGetTestCase(BaseTestGenerator):
|
||||
m_view_sql = "CREATE MATERIALIZED VIEW %s.%s TABLESPACE pg_default AS " \
|
||||
"SELECT 'test_pgadmin' WITH NO DATA;ALTER TABLE %s.%s OWNER" \
|
||||
" TO %s"
|
||||
view_sql_with_bracket = "CREATE OR REPLACE VIEW %s.%s AS " \
|
||||
"SELECT CASE WHEN (pg_db.datistemplate = false " \
|
||||
"AND pg_db.datallowconn = true AND " \
|
||||
"(pg_db.datconnlimit = -1 OR " \
|
||||
"pg_db.datacl is null)) then true else false " \
|
||||
"end as res FROM pg_database pg_db; " \
|
||||
"ALTER TABLE %s.%s OWNER TO %s"
|
||||
scenarios = [
|
||||
('Get view under schema node', dict(
|
||||
url='/browser/view/obj/',
|
||||
view_name="test_view_get_%s" % (str(uuid.uuid4())[1:8]),
|
||||
sql_query=view_sql)),
|
||||
sql_query=view_sql,
|
||||
type='view_without_conditions')),
|
||||
('Get materialized view under schema node',
|
||||
dict(url='/browser/mview/obj/',
|
||||
view_name="test_mview_get_%s" % (str(uuid.uuid4())[1:8]),
|
||||
sql_query=m_view_sql))
|
||||
sql_query=m_view_sql,
|
||||
type='m_view_without_conditions')),
|
||||
('Get view having brackets in script under schema node', dict(
|
||||
url='/browser/view/obj/',
|
||||
view_name="test_view_get_%s" % (str(uuid.uuid4())[1:8]),
|
||||
sql_query=view_sql_with_bracket,
|
||||
type='view_with_conditions'))
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
@ -77,6 +92,9 @@ class ViewsGetTestCase(BaseTestGenerator):
|
||||
follow_redirects=True
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
if self.type == 'view_with_conditions':
|
||||
response_data = json.loads(response.data.decode('utf-8'))
|
||||
self.assertIn('((pg_db.datistemplate', response_data['definition'])
|
||||
|
||||
def tearDown(self):
|
||||
# Disconnect the database
|
||||
|
Loading…
Reference in New Issue
Block a user