diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/acl.sql
index 60b2bf74a..eb3d6e7c5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/acl.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/acl.sql
@@ -1,4 +1,4 @@
-SELECT 'relacl' as deftype, privileges_information.grantee, privileges_information.grantor,
+SELECT 'relacl' as deftype, COALESCE(privileges_information.grantee, 'PUBLIC') grantee, privileges_information.grantor,
array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable
from (
SELECT
@@ -32,4 +32,4 @@ from (
GROUP BY privileges_information.grantee,privileges_information.grantor
-ORDER BY privileges_information.grantee
\ No newline at end of file
+ORDER BY privileges_information.grantee
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/test_utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/test_utils.py
index d8f80dc3e..7550ce4de 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/test_utils.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/test_utils.py
@@ -83,6 +83,7 @@ class DataTypeReaderTest(BaseTestGenerator):
@patch('pgadmin.browser.server_groups.servers.databases.schemas.utils.render_template')
def runTest(self, template_mock):
+ template_mock.return_value = 'Some SQL'
connection = Mock()
connection.execute_2darray.return_value = [
True,
@@ -104,7 +105,7 @@ class DataTypeReaderTest(BaseTestGenerator):
self.assertEqual(result[1], self.expected_function_output)
self.assertTrue(result[0])
- connection.execute_2darray.assert_called()
+ connection.execute_2darray.assert_called_with('Some SQL')
template_mock.assert_called_with(
self.expected_sql_template_path + '/get_types.sql',
condition=self.sql_condition,
diff --git a/web/pgadmin/feature_tests/datatype_test.json b/web/pgadmin/feature_tests/datatype_test.json
index 8ded72896..77bf7d999 100644
--- a/web/pgadmin/feature_tests/datatype_test.json
+++ b/web/pgadmin/feature_tests/datatype_test.json
@@ -1,173 +1,217 @@
-[
- {
- "datatype": [
- "smallint",
- "smallint",
- "integer",
- "integer",
- "bigint",
- "bigint",
- "decimal",
- "decimal",
- "numeric",
- "numeric",
- "float[]",
- "float[]",
- "real",
- "real[]",
- "bytea",
- "bytea[]"
- ],
- "input":[
- "-32767",
- "32767",
- "-2147483647",
- "2147483647",
- "-9223372036854775807",
- "9223372036854775807",
- "922337203685.4775807",
- "92203685.477",
- "922337203685.922337203685",
- "-92233720368547758.08",
- "ARRAY[1, 2, 3]",
- "ARRAY['nan', 'nan', 'nan']",
- "'Infinity'",
- "'{Infinity}'",
- "'E\\\\xDEADBEEF'",
- "ARRAY['E\\\\xDEADBEEF', 'E\\\\xDEADBEEF']"
- ],
- "output":[
- "-32767",
- "32767",
- "-2147483647",
- "2147483647",
- "-9223372036854775807",
- "9223372036854775807",
- "922337203685.4775807",
- "92203685.477",
- "922337203685.922337203685",
- "-92233720368547758.08",
- "{1,2,3}",
- "{NaN,NaN,NaN}",
- "Infinity",
- "{Infinity}",
- "[binary data]",
- "[binary data[]]"
- ]
+{
+ "datatype_minimum_version": {
+ "smallint": 0,
+ "integer": 0,
+ "bigint": 0,
+ "decimal": 0,
+ "numeric": 0,
+ "float[]": 0,
+ "real": 0,
+ "real[]": 0,
+ "bytea": 0,
+ "bytea[]": 0,
+ "int4range": 90200,
+ "int8range": 90200,
+ "numrange": 90200,
+ "daterange": 90200,
+ "tsrange": 90200,
+ "tstzrange": 90200,
+ "int4range[]": 90200,
+ "int8range[]": 90200,
+ "numrange[]": 90200,
+ "daterange[]": 90200,
+ "tsrange[]": 90200,
+ "tstzrange[]": 90200,
+ "inet": 0,
+ "inet[]": 0,
+ "cidr": 0,
+ "cidr[]": 0,
+ "uuid": 0,
+ "uuid[]": 0,
+ "xml": 0,
+ "xml[]": 0,
+ "bit": 0,
+ "bit[]": 0,
+ "varbit": 0,
+ "varbit[]": 0,
+ "macaddr": 0,
+ "macaddr[]": 0,
+ "text": 0
},
- {
- "datatype": [
- "int4range",
- "int8range",
- "numrange",
- "daterange",
- "tsrange",
- "tstzrange",
- "int4range[]",
- "int8range[]",
- "numrange[]",
- "daterange[]",
- "tsrange[]",
- "tstzrange[]",
- "int8range[]",
- "daterange[]",
- "tstzrange[]",
- "",
- ""
- ],
- "input":[
- "'(1,2147483647)'",
- "'(2,9223372036854775807)'",
- "'(3,922337203685.922337203685]'",
- "'(2010-01-01, 2010-02-01]'",
- "'[2010-01-01 14:00, 2010-04-01 15:00)'",
- "'[2010-01-01 14:00:00{tz}, 2010-02-01 15:00:00{tz})'",
- "'{\"(1,2147483647)\", \"(2,2147483647)\"}'",
- "'{\"(2,9223372036854775807)\", \"(2,9223372036854775807)\"}'",
- "'{\"(3,922337203685.922337203685]\", \"(5,922337203685.922337203685]\"}'",
- "'{\"(2010-01-01, 2010-02-01]\", \"(2010-01-01, 2010-02-01]\"}'",
- "'{\"[2010-01-01 14:00, 2010-04-01 15:00)\", \"[2010-01-01 14:00, 2010-04-01 15:00)\"}'",
- "'{{\"[2010-01-01 14:00:00{tz}, 2010-02-01 15:00:00{tz})\", \"[2017-01-12 14:00:00{tz}, 2017-02-28 15:00:00{tz})\"}}'",
- "'{{\"(2,9223372036854775807)\", \"(2,9223372036854775807)\"},{\"(2,9223372036854775807)\", \"(2,9223372036854775807)\"}}'",
- "'{{\"(2010-01-01, 2010-02-01]\", \"(2010-01-01, 2010-02-01]\"},{\"(2010-01-01, 2010-02-01]\", \"(2010-01-01, 2010-02-01]\"}}'",
- "'{{{{\"[2010-01-01 14:00:00{tz}, 2010-02-01 15:00:00{tz})\", \"[2017-01-12 14:00:00{tz}, 2017-02-28 15:00:00{tz})\"}}, {{\"[2010-01-01 14:00:00{tz}, 2010-02-01 15:00:00{tz})\", \"[2017-01-12 14:00:00{tz}, 2017-02-28 15:00:00{tz})\"}}}}'",
- "enum_range(NULL::rainbow)",
- "ARRAY[enum_range(NULL::rainbow), enum_range(NULL::rainbow)]"
- ],
- "output":[
- "[2,2147483647)",
- "[3,9223372036854775807)",
- "(3,922337203685.922337203685]",
- "[2010-01-02,2010-02-02)",
- "[\"2010-01-01 14:00:00\",\"2010-04-01 15:00:00\")",
- "[\"2010-01-01 14:00:00{tz}\",\"2010-02-01 15:00:00{tz}\")",
- "{\"[2,2147483647)\",\"[3,2147483647)\"}",
- "{\"[3,9223372036854775807)\",\"[3,9223372036854775807)\"}",
- "{\"(3,922337203685.922337203685]\",\"(5,922337203685.922337203685]\"}",
- "{\"[2010-01-02,2010-02-02)\",\"[2010-01-02,2010-02-02)\"}",
- "{\"[\\\"2010-01-01 14:00:00\\\",\\\"2010-04-01 15:00:00\\\")\",\"[\\\"2010-01-01 14:00:00\\\",\\\"2010-04-01 15:00:00\\\")\"}",
- "{{\"[\\\"2010-01-01 14:00:00{tz}\\\",\\\"2010-02-01 15:00:00{tz}\\\")\",\"[\\\"2017-01-12 14:00:00{tz}\\\",\\\"2017-02-28 15:00:00{tz}\\\")\"}}",
- "{{\"[3,9223372036854775807)\",\"[3,9223372036854775807)\"},{\"[3,9223372036854775807)\",\"[3,9223372036854775807)\"}}",
- "{{\"[2010-01-02,2010-02-02)\",\"[2010-01-02,2010-02-02)\"},{\"[2010-01-02,2010-02-02)\",\"[2010-01-02,2010-02-02)\"}}",
- "{{{{\"[\\\"2010-01-01 14:00:00{tz}\\\",\\\"2010-02-01 15:00:00{tz}\\\")\",\"[\\\"2017-01-12 14:00:00{tz}\\\",\\\"2017-02-28 15:00:00{tz}\\\")\"}},{{\"[\\\"2010-01-01 14:00:00{tz}\\\",\\\"2010-02-01 15:00:00{tz}\\\")\",\"[\\\"2017-01-12 14:00:00{tz}\\\",\\\"2017-02-28 15:00:00{tz}\\\")\"}}}}",
- "{red,orange,yellow,green,blue,purple}",
- "{{red,orange,yellow,green,blue,purple},{red,orange,yellow,green,blue,purple}}"
- ]
- },
- {
- "datatype": [
- "inet",
- "inet[]",
- "inet[]",
- "cidr",
- "cidr[]",
- "cidr[]",
- "uuid",
- "uuid[]",
- "xml",
- "xml[]",
- "bit",
- "bit[]",
- "varbit",
- "varbit[]",
- "macaddr",
- "macaddr[]"
- ],
- "input":[
- "'::2'",
- "'{\"::2\",\"192.168.1.1/16\",\"FFF0:0:007a::\"}'",
- "'{{\"::2\",\"192.168.1.1/16\",\"FFF0:0:007a::\"},{\"::2\",\"192.168.1.1/16\",\"FFF0:0:007a::\"}}'",
- "'::1'",
- "'{\"::1\", \"192.168.100.128/25\", \"FFF0:0:007a::\"}'",
- "'{{\"::1\", \"192.168.100.128/25\", \"FFF0:0:007a::\"},{\"::1\", \"192.168.100.128/25\", \"FFF0:0:007a::\"}}'",
- "'e1ab7b6d-a62d-4bee-b0ce-b8488f83d89c'",
- "'{55f8e502-e0b4-11e7-80c1-9a214cf093ae, e1ab7b6d-a62d-4bee-b0ce-b8488f83d89c}'",
- "'pgAdmin 4'",
- "'{\"pgAdmin 4\", \"pgAdmin 4\"}'",
- "'1'",
- "'{0,1}'",
- "'1001'",
- "'{10010,1011}'",
- "'08:00:2b:01:02:03'",
- "'{08:00:2b:01:02:03, 08-00-2b-01-02-03, 08002b:010203, 08002b-010203, 0800.2b01.0203, 0800-2b01-0203, 08002b010203}'"
- ],
- "output":[
- "::2",
- "{::2,192.168.1.1/16,fff0:0:7a::}",
- "{{::2,192.168.1.1/16,fff0:0:7a::},{::2,192.168.1.1/16,fff0:0:7a::}}",
- "::1/128",
- "{::1/128,192.168.100.128/25,fff0:0:7a::/128}",
- "{{::1/128,192.168.100.128/25,fff0:0:7a::/128},{::1/128,192.168.100.128/25,fff0:0:7a::/128}}",
- "e1ab7b6d-a62d-4bee-b0ce-b8488f83d89c",
- "{55f8e502-e0b4-11e7-80c1-9a214cf093ae,e1ab7b6d-a62d-4bee-b0ce-b8488f83d89c}",
- "pgAdmin 4",
- "{\"pgAdmin 4\",\"pgAdmin 4\"}",
- "1",
- "{0,1}",
- "1001",
- "{10010,1011}",
- "08:00:2b:01:02:03",
- "{08:00:2b:01:02:03,08:00:2b:01:02:03,08:00:2b:01:02:03,08:00:2b:01:02:03,08:00:2b:01:02:03,08:00:2b:01:02:03,08:00:2b:01:02:03}"
- ]
- }
-]
\ No newline at end of file
+ "tests": [
+ {
+ "datatype": [
+ "smallint",
+ "smallint",
+ "integer",
+ "integer",
+ "bigint",
+ "bigint",
+ "decimal",
+ "decimal",
+ "numeric",
+ "numeric",
+ "float[]",
+ "float[]",
+ "real",
+ "real[]",
+ "bytea",
+ "bytea[]"
+ ],
+ "input": [
+ "-32767",
+ "32767",
+ "-2147483647",
+ "2147483647",
+ "-9223372036854775807",
+ "9223372036854775807",
+ "922337203685.4775807",
+ "92203685.477",
+ "922337203685.922337203685",
+ "-92233720368547758.08",
+ "ARRAY[1, 2, 3]",
+ "ARRAY['nan', 'nan', 'nan']",
+ "'Infinity'",
+ "'{Infinity}'",
+ "'E\\\\xDEADBEEF'",
+ "ARRAY['E\\\\xDEADBEEF', 'E\\\\xDEADBEEF']"
+ ],
+ "output": [
+ "-32767",
+ "32767",
+ "-2147483647",
+ "2147483647",
+ "-9223372036854775807",
+ "9223372036854775807",
+ "922337203685.4775807",
+ "92203685.477",
+ "922337203685.922337203685",
+ "-92233720368547758.08",
+ "{1,2,3}",
+ "{NaN,NaN,NaN}",
+ "Infinity",
+ "{Infinity}",
+ "[binary data]",
+ "[binary data[]]"
+ ]
+ },
+ {
+ "datatype": [
+ "text",
+ "int4range",
+ "int8range",
+ "numrange",
+ "daterange",
+ "tsrange",
+ "tstzrange",
+ "int4range[]",
+ "int8range[]",
+ "numrange[]",
+ "daterange[]",
+ "tsrange[]",
+ "tstzrange[]",
+ "int8range[]",
+ "daterange[]",
+ "tstzrange[]",
+ "",
+ ""
+ ],
+ "input": [
+ "'some input'",
+ "'(1,2147483647)'",
+ "'(2,9223372036854775807)'",
+ "'(3,922337203685.922337203685]'",
+ "'(2010-01-01, 2010-02-01]'",
+ "'[2010-01-01 14:00, 2010-04-01 15:00)'",
+ "'[2010-01-01 14:00:00{tz}, 2010-02-01 15:00:00{tz})'",
+ "'{\"(1,2147483647)\", \"(2,2147483647)\"}'",
+ "'{\"(2,9223372036854775807)\", \"(2,9223372036854775807)\"}'",
+ "'{\"(3,922337203685.922337203685]\", \"(5,922337203685.922337203685]\"}'",
+ "'{\"(2010-01-01, 2010-02-01]\", \"(2010-01-01, 2010-02-01]\"}'",
+ "'{\"[2010-01-01 14:00, 2010-04-01 15:00)\", \"[2010-01-01 14:00, 2010-04-01 15:00)\"}'",
+ "'{{\"[2010-01-01 14:00:00{tz}, 2010-02-01 15:00:00{tz})\", \"[2017-01-12 14:00:00{tz}, 2017-02-28 15:00:00{tz})\"}}'",
+ "'{{\"(2,9223372036854775807)\", \"(2,9223372036854775807)\"},{\"(2,9223372036854775807)\", \"(2,9223372036854775807)\"}}'",
+ "'{{\"(2010-01-01, 2010-02-01]\", \"(2010-01-01, 2010-02-01]\"},{\"(2010-01-01, 2010-02-01]\", \"(2010-01-01, 2010-02-01]\"}}'",
+ "'{{{{\"[2010-01-01 14:00:00{tz}, 2010-02-01 15:00:00{tz})\", \"[2017-01-12 14:00:00{tz}, 2017-02-28 15:00:00{tz})\"}}, {{\"[2010-01-01 14:00:00{tz}, 2010-02-01 15:00:00{tz})\", \"[2017-01-12 14:00:00{tz}, 2017-02-28 15:00:00{tz})\"}}}}'",
+ "enum_range(NULL::rainbow)",
+ "ARRAY[enum_range(NULL::rainbow), enum_range(NULL::rainbow)]"
+ ],
+ "output": [
+ "some input",
+ "[2,2147483647)",
+ "[3,9223372036854775807)",
+ "(3,922337203685.922337203685]",
+ "[2010-01-02,2010-02-02)",
+ "[\"2010-01-01 14:00:00\",\"2010-04-01 15:00:00\")",
+ "[\"2010-01-01 14:00:00{tz}\",\"2010-02-01 15:00:00{tz}\")",
+ "{\"[2,2147483647)\",\"[3,2147483647)\"}",
+ "{\"[3,9223372036854775807)\",\"[3,9223372036854775807)\"}",
+ "{\"(3,922337203685.922337203685]\",\"(5,922337203685.922337203685]\"}",
+ "{\"[2010-01-02,2010-02-02)\",\"[2010-01-02,2010-02-02)\"}",
+ "{\"[\\\"2010-01-01 14:00:00\\\",\\\"2010-04-01 15:00:00\\\")\",\"[\\\"2010-01-01 14:00:00\\\",\\\"2010-04-01 15:00:00\\\")\"}",
+ "{{\"[\\\"2010-01-01 14:00:00{tz}\\\",\\\"2010-02-01 15:00:00{tz}\\\")\",\"[\\\"2017-01-12 14:00:00{tz}\\\",\\\"2017-02-28 15:00:00{tz}\\\")\"}}",
+ "{{\"[3,9223372036854775807)\",\"[3,9223372036854775807)\"},{\"[3,9223372036854775807)\",\"[3,9223372036854775807)\"}}",
+ "{{\"[2010-01-02,2010-02-02)\",\"[2010-01-02,2010-02-02)\"},{\"[2010-01-02,2010-02-02)\",\"[2010-01-02,2010-02-02)\"}}",
+ "{{{{\"[\\\"2010-01-01 14:00:00{tz}\\\",\\\"2010-02-01 15:00:00{tz}\\\")\",\"[\\\"2017-01-12 14:00:00{tz}\\\",\\\"2017-02-28 15:00:00{tz}\\\")\"}},{{\"[\\\"2010-01-01 14:00:00{tz}\\\",\\\"2010-02-01 15:00:00{tz}\\\")\",\"[\\\"2017-01-12 14:00:00{tz}\\\",\\\"2017-02-28 15:00:00{tz}\\\")\"}}}}",
+ "{red,orange,yellow,green,blue,purple}",
+ "{{red,orange,yellow,green,blue,purple},{red,orange,yellow,green,blue,purple}}"
+ ]
+ },
+ {
+ "datatype": [
+ "inet",
+ "inet[]",
+ "inet[]",
+ "cidr",
+ "cidr[]",
+ "cidr[]",
+ "uuid",
+ "uuid[]",
+ "xml",
+ "xml[]",
+ "bit",
+ "bit[]",
+ "varbit",
+ "varbit[]",
+ "macaddr",
+ "macaddr[]"
+ ],
+ "input": [
+ "'::2'",
+ "'{\"::2\",\"192.168.1.1/16\",\"FFF0:0:007a::\"}'",
+ "'{{\"::2\",\"192.168.1.1/16\",\"FFF0:0:007a::\"},{\"::2\",\"192.168.1.1/16\",\"FFF0:0:007a::\"}}'",
+ "'::1'",
+ "'{\"::1\", \"192.168.100.128/25\", \"FFF0:0:007a::\"}'",
+ "'{{\"::1\", \"192.168.100.128/25\", \"FFF0:0:007a::\"},{\"::1\", \"192.168.100.128/25\", \"FFF0:0:007a::\"}}'",
+ "'e1ab7b6d-a62d-4bee-b0ce-b8488f83d89c'",
+ "'{55f8e502-e0b4-11e7-80c1-9a214cf093ae, e1ab7b6d-a62d-4bee-b0ce-b8488f83d89c}'",
+ "'pgAdmin 4'",
+ "'{\"pgAdmin 4\", \"pgAdmin 4\"}'",
+ "'1'",
+ "'{0,1}'",
+ "'1001'",
+ "'{10010,1011}'",
+ "'08:00:2b:01:02:03'",
+ "'{08:00:2b:01:02:03, 08-00-2b-01-02-03, 08002b:010203, 08002b-010203, 0800.2b01.0203, 08002b010203}'"
+ ],
+ "output": [
+ "::2",
+ "{::2,192.168.1.1/16,fff0:0:7a::}",
+ "{{::2,192.168.1.1/16,fff0:0:7a::},{::2,192.168.1.1/16,fff0:0:7a::}}",
+ "::1/128",
+ "{::1/128,192.168.100.128/25,fff0:0:7a::/128}",
+ "{{::1/128,192.168.100.128/25,fff0:0:7a::/128},{::1/128,192.168.100.128/25,fff0:0:7a::/128}}",
+ "e1ab7b6d-a62d-4bee-b0ce-b8488f83d89c",
+ "{55f8e502-e0b4-11e7-80c1-9a214cf093ae,e1ab7b6d-a62d-4bee-b0ce-b8488f83d89c}",
+ "pgAdmin 4",
+ "{\"pgAdmin 4\",\"pgAdmin 4\"}",
+ "1",
+ "{0,1}",
+ "1001",
+ "{10010,1011}",
+ "08:00:2b:01:02:03",
+ "{08:00:2b:01:02:03,08:00:2b:01:02:03,08:00:2b:01:02:03,08:00:2b:01:02:03,08:00:2b:01:02:03,08:00:2b:01:02:03}"
+ ]
+ }
+ ]
+}
diff --git a/web/pgadmin/feature_tests/pg_datatype_validation_test.py b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
index e39f10bbb..c12b18119 100644
--- a/web/pgadmin/feature_tests/pg_datatype_validation_test.py
+++ b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
@@ -23,7 +23,9 @@ CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
try:
with open(CURRENT_PATH + '/datatype_test.json') as data_file:
- config_data = json.load(data_file)
+ test_data_configuration = json.load(data_file)
+ config_data = test_data_configuration['tests']
+ type_minimum_version = test_data_configuration['datatype_minimum_version']
except Exception as e:
print(str(e))
@@ -64,6 +66,8 @@ class PGDataypeFeatureTest(BaseFeatureTest):
test_utils.drop_database(connection, "acceptance_test_db")
test_utils.create_database(self.server, "acceptance_test_db")
+ self.database_version = connection.server_version
+
# For this test case we need to set "Insert bracket pairs?"
# SQL Editor preference to 'false' to avoid codemirror
# to add matching closing bracket by it self.
@@ -167,6 +171,10 @@ class PGDataypeFeatureTest(BaseFeatureTest):
for val, cell, datatype in zip(batch['output'], cells, batch['datatype']):
expected_output = batch['output'][cnt - 2]
+ if not self._is_datatype_available_in_current_database(datatype):
+ cnt += 1
+ continue
+
if datatype in ('tstzrange', 'tstzrange[]'):
expected_output = expected_output.format(
**dict([('tz', self.timezone_hh_mm)]))
@@ -190,6 +198,9 @@ class PGDataypeFeatureTest(BaseFeatureTest):
query = 'SELECT '
first = True
for datatype, inputdata in zip(batch['datatype'], batch['input']):
+ if not self._is_datatype_available_in_current_database(datatype):
+ continue
+
if datatype != '':
dataformatter = '{}::{}'
else:
@@ -223,3 +234,6 @@ class PGDataypeFeatureTest(BaseFeatureTest):
self.page.find_by_xpath("//*[@id='btn-clear']")
)
self.page.click_modal('Yes')
+
+ def _is_datatype_available_in_current_database(self, datatype):
+ return datatype == '' or self.database_version >= type_minimum_version[datatype]