Fixed display SQL of table with index for GreenPlum database. Fixes #3306

pull/9/head
Joao De Almeida Pereira 2018-04-25 12:36:41 +05:30 committed by Akshay Joshi
parent b653b742ed
commit 2ace6a60f3
5 changed files with 92 additions and 24 deletions

View File

@ -15,4 +15,6 @@ Bug fixes
*********
| `Bug #3179 <https://redmine.postgresql.org/issues/3179>`_ - Fix an error generating SQL for trigger functions
| `Bug #3257 <https://redmine.postgresql.org/issues/3257>`_ - Catch errors when trying to EXPLAIN an invalid query
| `Bug #3257 <https://redmine.postgresql.org/issues/3257>`_ - Catch errors when trying to EXPLAIN an invalid query
| `Bug #3290 <https://redmine.postgresql.org/issues/3290>`_ - Close button added to the alertify message box, which pops up in case of backend error
| `Bug #3306 <https://redmine.postgresql.org/issues/3306>`_ - Fixed display SQL of table with index for GreenPlum database

View File

@ -0,0 +1,72 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2018, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
import sys
from pgadmin.browser.server_groups.servers.databases.schemas.tables import \
BaseTableView
from pgadmin.utils.route import BaseTestGenerator
if sys.version_info < (3, 3):
from mock import patch, MagicMock
else:
from unittest.mock import patch, MagicMock
class TestBaseView(BaseTableView):
@BaseTableView.check_precondition
def test(self, did, sid):
pass
class TestUtils(BaseTestGenerator):
scenarios = [
('Test wrapping function', dict(test='wrap'))
]
def runTest(self):
if self.test == 'wrap':
self.__wrap_tests()
def __wrap_tests(self):
subject = TestBaseView(cmd='something')
with patch('pgadmin.browser.server_groups.servers.databases.schemas'
'.tables.utils.get_driver') as get_driver_mock:
get_driver_mock.return_value = MagicMock(
connection_manager=MagicMock(
return_value=MagicMock(
connection=MagicMock(),
db_info={
1: dict(datlastsysoid=False)
},
version=10,
server_type='gpdb'
)
),
qtIndent=MagicMock(),
qtTypeIdent=MagicMock()
)
subject.test(did=1, sid=2)
self.assertEqual(
subject.table_template_path, 'table/sql/#gpdb#10#')
self.assertEqual(
subject.data_type_template_path, 'datatype/sql/#gpdb#10#')
self.assertEqual(
subject.check_constraint_template_path,
'check_constraint/sql/#gpdb#10#')
self.assertEqual(
subject.exclusion_constraint_template_path,
'exclusion_constraint/sql/#gpdb#10#')
self.assertEqual(
subject.foreign_key_template_path,
'foreign_key/sql/#gpdb#10#')
self.assertEqual(
subject.index_template_path,
'index/sql/#gpdb#10#')
self.assertEqual(
subject.trigger_template_path,
'trigger/sql/#gpdb#10#')

View File

@ -22,6 +22,7 @@ from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
parse_priv_to_db
from pgadmin.browser.utils import PGChildNodeView
from pgadmin.utils import IS_PY2
from pgadmin.utils.compile_template_name import compile_template_path
from pgadmin.utils.driver import get_driver
from config import PG_DEFAULT_DRIVER
@ -106,38 +107,36 @@ class BaseTableView(PGChildNodeView):
ver = self.manager.version
server_type = self.manager.server_type
# Set the template path for the SQL scripts
self.table_template_path = 'table/sql/' + (
'#{0}#{1}#'.format(server_type, ver)
if server_type == 'gpdb' else
'#{0}#'.format(ver)
)
self.data_type_template_path = 'datatype/sql/' + (
'#{0}#{1}#'.format(server_type, ver) if
server_type == 'gpdb' else'#{0}#'.format(ver)
)
self.table_template_path = compile_template_path('table/sql',
server_type, ver)
self.data_type_template_path = compile_template_path(
'datatype/sql',
server_type, ver)
self.partition_template_path = \
'partition/sql/{0}/#{0}#{1}#'.format(server_type, ver)
# Template for Column ,check constraint and exclusion
# constraint node
self.column_template_path = 'column/sql/#{0}#'.format(ver)
self.check_constraint_template_path = \
'check_constraint/sql/#{0}#'.format(ver)
self.exclusion_constraint_template_path = \
'exclusion_constraint/sql/#{0}#'.format(ver)
self.check_constraint_template_path = compile_template_path(
'check_constraint/sql', server_type, ver)
self.exclusion_constraint_template_path = compile_template_path(
'exclusion_constraint/sql', server_type, ver)
# Template for PK & Unique constraint node
self.index_constraint_template_path = 'index_constraint/sql'
# Template for foreign key constraint node
self.foreign_key_template_path = \
'foreign_key/sql/#{0}#'.format(ver)
self.foreign_key_template_path = compile_template_path(
'foreign_key/sql', server_type, ver)
# Template for index node
self.index_template_path = 'index/sql/#{0}#'.format(ver)
self.index_template_path = compile_template_path(
'index/sql', server_type, ver)
# Template for trigger node
self.trigger_template_path = 'trigger/sql/#{0}#'.format(ver)
self.trigger_template_path = compile_template_path(
'trigger/sql', server_type, ver)
# Template for rules node
self.rules_template_path = 'rules/sql'

View File

@ -6,7 +6,6 @@
# This software is released under the PostgreSQL Licence
#
##########################################################################
import os
def compile_template_name(

View File

@ -10,11 +10,7 @@ from pgadmin.utils.compile_template_name import compile_template_name
from pgadmin.utils.route import BaseTestGenerator
class StartRunningQueryTest(BaseTestGenerator):
"""
Check that the apply_explain_plan_weapper_if_needed method works as
intended
"""
class TestCompileTemplateName(BaseTestGenerator):
scenarios = [
(
'When server is Postgres and version is 10, it returns the path '