Hi,

PFA add-on patch for table and it's child node. (please apply this patch on
version 6 patch)

Murtuza and I fixed following issues:

1. SQL formatting
2. Vacuum grid should not be editable in properties mode.
3. Column datatype does not get displayed in the properties and edit mode.
4. Do not allow to add another primary key if one already exist.

And another minor enhancements.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Sat, May 14, 2016 at 2:03 AM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

>
> Hi,
>
>
> PFA updated patches (version: 6) for table and it's child nodes.
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
> On Fri, May 13, 2016 at 6:55 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Review Comments:
>>
>> - Please replace 'can not' with 'cannot'  in all the validation messages.
>> - PG 9.1+ Inheritance issue as below:
>>
>> CREATE TABLE public.table1
>> (
>> )
>> (
>> )
>>     INHERITS (a)
>> WITH (
>>     OIDS = FALSE
>> )
>> TABLESPACE pg_default;
>> ALTER TABLE public.table1
>>     OWNER to postgres;
>>
>>
>> brackets are coming twice.
>>
> Fixed
>
>
>>
>> - Please maintain one line spacing between SQL queries In the SQL Tab.
>>
> TODO
>
>
>> - Foreign Key Grid in Table css issue: Grid columns expands on the
>> selection of the cell
>>
> Fixed
>
>
>> - Check Constraint: Validated? option should be True by default
>>
> Not sure about this. I cross checked in pgadmin3.
>
>
>
>> - pg 9.4: Exclude constraint does not render in SQL tab
>>
> Fixed
>
>
>> - Missing Security validation
>>
> Fixed
>
>
>> - Vacuum grid should not be editable in properties mode.
>>
> TODO (It's editable but one cannot save it on server from here as there is
> no save button.)
>
>
>> - Edit mode, Fill Factor can be allowed to be null.
>>
> TODO (This is generic issue in Integer and Numeric controls. This issue is
> covered in this partial patch
> <http://www.postgresql.org/message-id/cafip3vzvtqxjmpzeeav4pd0p7cevcrrdfgdwuvu4cyhnthp...@mail.gmail.com>
> )
>
>
>> - While dropping inheritance, related table columns drop SQL are also
>> populated in the SQL Tab
>>
>> ALTER TABLE public."Tbl"
>>     NO INHERIT b;
>> ALTER TABLE public."Tbl" DROP COLUMN id;
>> ALTER TABLE public."Tbl" DROP COLUMN name;
>>
>>
> Fixed
>
>
>
>>
>> And also render error while clicking on the save button.
>>
>> ERROR: syntax error at or near "["
>> LINE 2: INHERIT [;
>>
>> ^
>>
>> Fixed
>
>
>> - in a Reverse Engineering SQL tab, schema_name.tablename should be
>> there, currently only table_name displays.
>>
> Fixed
>
>
>
>> - Column SQL is showing below text with HTML
>>
>>
>> <html><head></head><body>-- Column: id -- ALTER TABLE public.a DROIP
>> COLUMN id; ALTER TABLE public.a ADD COLUMN id integer;</body></html>
>>
>>
> I was not able to reproduce exact issue but still I have fixed other issue
> which I found related to column SQL. Hopefully that will fix this issue as
> well.
>
>
>> - The column datatype dependency does not get cleared upon selection of
>> another datatype.
>>
>  For example, if I select numeric and gives the length and precision.
>> After that I change the dat-type then, dependent fields should be get
>> cleared.
>>
> Fixed.
>
>
>>
>> - The column datatype does not get displayed in the properties and edit
>> mode if the length and precision are given while creating a column.
>>
>
> TODO ( I cannot fix this blindly as this might introduce another issue(s)
> in column node. I will need Murtuza's help as he has worked on column node)
>
>
>>
>> - Statistics is showing null value even after having value.
>>
> Fixed
>
>
>>
>> - if the check constraints are not validated then put proper icon in tree
>> and also it should be validated in edit mode.
>>
> Not reproducible.
>
>
>>
>> NOTE: I have not checked the Indexes, Triggers and Rules nodes as I do
>> not have much knowledge about it.
>>
>>
>
>
>> Thanks,
>> Khushboo
>>
>> On Fri, May 13, 2016 at 5:24 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi
>>>
>>> PFA attached patches for table and it's child nodes with python 2.7
>>> compatibility.
>>>
>>>
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index a51d5eb..c561159 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -656,10 +656,31 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
                 # Manual Data type formatting
                 # If data type has () with them then we need to remove them
                 # eg bit(1) because we need to match the name with combobox
+                isArray = False
+                if column['cltype'].endswith('[]'):
+                    isArray = True
+                    column['cltype'] = column['cltype'].rstrip('[]')
+
                 idx = column['cltype'].find('(')
                 if idx and column['cltype'].endswith(')'):
                     column['cltype'] = column['cltype'][:idx]
 
+                if isArray:
+                    column['cltype'] += "[]"
+
+                if 'indkey' in column:
+                    # Current column
+                    attnum = str(column['attnum'])
+
+                    # Single/List of primary key column(s)
+                    indkey = str(column['indkey'])
+
+                    # We will check if column is in primary column(s)
+                    if attnum in indkey.split(" "):
+                        column['is_primary_key'] = True
+                    else:
+                        column['is_primary_key'] = False
+
         return data
 
     def _index_constraints_formatter(self, tid, data):
@@ -679,6 +700,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
         }
 
         for ctype in index_constraints.keys():
+            data[index_constraints[ctype]] = []
+
             sql = render_template("/".join([self.index_constraint_template_path,
                                             'properties.sql']),
                                   tid=tid,
@@ -1058,6 +1081,23 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
         if not status:
             return internal_server_error(errormsg=res)
         data = res['rows'][0]
+
+        data['vacuum_settings_str'] = ""
+
+        if data['table_vacuum_settings_str'] is not None:
+            data['vacuum_settings_str'] += data[
+                'table_vacuum_settings_str'].replace(',', '\n')
+
+        if data['toast_table_vacuum_settings_str'] is not None:
+            data['vacuum_settings_str'] += '\n' + '\n'.join(
+                    ['toast_' + setting for setting in data[
+                        'toast_table_vacuum_settings_str'
+                    ].split(',')]
+                )
+        data['vacuum_settings_str'] = data[
+            'vacuum_settings_str'
+        ].replace("=", " = ")
+
         data = self._formatter(scid, tid, data)
 
         return ajax_response(
@@ -1615,7 +1655,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 
         try:
             SQL = self.get_sql(scid, tid, data)
-            re.sub('\n{2,}', '\n', SQL)
+            SQL = re.sub('\n{2,}', '\n', SQL)
             SQL = SQL.strip('\n')
             return make_json_response(
                 data=SQL,
@@ -2391,6 +2431,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
                                     data=data, conn=self.conn)
 
         # Add into main sql
+        table_sql = re.sub('\n{2,}', '\n\n', table_sql)
         main_sql.append(table_sql.strip('\n'))
 
         """
@@ -2473,6 +2514,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
                                          data=data, conn=self.conn)
 
             # Add into main sql
+            index_sql = re.sub('\n{2,}', '\n\n', index_sql)
             main_sql.append(sql_header + '\n\n' + index_sql.strip('\n'))
 
         """
@@ -2525,30 +2567,31 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 
                 data['columns'] = columns
 
-                data = trigger_definition(data)
+            data = trigger_definition(data)
 
-                sql_header = "\n-- Trigger: {0}\n\n-- ".format(data['name'])
-                sql_header += render_template("/".join([self.trigger_template_path,
-                                                        'delete.sql']),
-                                              data=data, conn=self.conn)
+            sql_header = "\n-- Trigger: {0}\n\n-- ".format(data['name'])
+            sql_header += render_template("/".join([self.trigger_template_path,
+                                                    'delete.sql']),
+                                          data=data, conn=self.conn)
 
-                # If the request for new object which do not have did
-                trigger_sql = render_template("/".join([self.trigger_template_path,
-                                                        'create.sql']),
-                                              data=data, conn=self.conn)
+            # If the request for new object which do not have did
+            trigger_sql = render_template("/".join([self.trigger_template_path,
+                                                    'create.sql']),
+                                          data=data, conn=self.conn)
 
-                trigger_sql = sql_header + '\n\n' + trigger_sql.strip('\n')
+            trigger_sql = sql_header + '\n\n' + trigger_sql.strip('\n')
 
-                # If trigger is disabled then add sql code for the same
-                if not data['is_enable_trigger']:
-                    trigger_sql += '\n\n'
-                    trigger_sql += render_template("/".join([
-                        self.trigger_template_path,
-                        'enable_disable_trigger.sql']),
-                        data=data, conn=self.conn)
+            # If trigger is disabled then add sql code for the same
+            if not data['is_enable_trigger']:
+                trigger_sql += '\n\n'
+                trigger_sql += render_template("/".join([
+                    self.trigger_template_path,
+                    'enable_disable_trigger.sql']),
+                    data=data, conn=self.conn)
 
             # Add into main sql
-            main_sql.append(trigger_sql.strip('\n'))
+            trigger_sql = re.sub('\n{2,}', '\n\n', trigger_sql)
+            main_sql.append(trigger_sql)
 
         """
         #####################################
@@ -2579,6 +2622,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
                 data=res_data, display_comments=True)
 
             # Add into main sql
+            rules_sql = re.sub('\n{2,}', '\n\n', rules_sql)
             main_sql.append(rules_sql)
 
         sql = '\n'.join(main_sql)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
index 1f85b90..49d2c7b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
@@ -316,7 +316,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
             indkey = str(data['indkey'])
 
             # We will check if column is in primary column(s)
-            if attnum in indkey:
+            if attnum in indkey.split(" "):
                 data['is_pk'] = True
             else:
                 data['is_pk'] = False
@@ -328,13 +328,20 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
         )
 
         import re
+        # If we have length & precision both
         matchObj = re.search(r'(\d+),(\d+)', fulltype)
         if matchObj:
             data['attlen'] = matchObj.group(1)
             data['attprecision'] = matchObj.group(2)
         else:
-            data['attlen'] = None
-            data['attprecision'] = None
+            # If we have length only
+            matchObj = re.search(r'(\d+)', fulltype)
+            if matchObj:
+                data['attlen'] = matchObj.group(1)
+                data['attprecision'] = None
+            else:
+                data['attlen'] = None
+                data['attprecision'] = None
 
         # We need to fetch inherited tables for each table
         SQL = render_template("/".join([self.template_path,
@@ -410,12 +417,20 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
 
         data['edit_types'] = edit_types_list
 
-        # Custom Data type formatting
-        # If data type is bit then db returns bit(1),
-        # So we need to convert those types manually
-        if data['cltype'] == 'bit(1)':
-            data['cltype'] = 'bit'
+        # Manual Data type formatting
+        # If data type has () with them then we need to remove them
+        # eg bit(1) because we need to match the name with combobox
+        isArray = False
+        if data['cltype'].endswith('[]'):
+            isArray = True
+            data['cltype'] = data['cltype'].rstrip('[]')
+
+        idx = data['cltype'].find('(')
+        if idx and data['cltype'].endswith(')'):
+            data['cltype'] = data['cltype'][:idx]
 
+        if isArray:
+            data['cltype'] += "[]"
 
         return data
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js
index 23e2d25..15716c8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js
@@ -137,7 +137,6 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
         }
         ]);
       },
-      canDrop: pgBrowser.Nodes['schema'].canChildDrop,
       model: pgAdmin.Browser.Node.Model.extend({
         defaults: {
           name: undefined,
@@ -173,6 +172,13 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
             return _.isUndefined(m.top.node_info['table']);
           },
           disabled: function(m){
+            // If primary key already exist then disable.
+            if (m.top && !_.isUndefined(m.top.get('oid')) &&
+                        m.top.get('primary_key').length > 0 &&
+                        !_.isUndefined(m.top.get('primary_key').first().get('oid'))) {
+              return true;
+            }
+
             var name = m.get('name');
 
             if(!m.inSchemaWithColumnCheck.apply(this, [m]) &&
@@ -187,6 +193,14 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
             if(m instanceof Backbone.Collection) {
               return true;
             }
+            // If primary key already exist then disable.
+            if (m.top && !_.isUndefined(m.top.get('oid')) &&
+                      m.top.get('primary_key').length > 0 &&
+                      !_.isUndefined(m.top.get('primary_key').first().get('oid'))) {
+
+              return false;
+            }
+
             if(!m.inSchemaWithColumnCheck.apply(this, [m]) &&
               !_.isUndefined(name) && !_.isNull(name) && name !== '') {
               return true;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index/sql/9.1_plus/alter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index/sql/9.1_plus/alter.sql
index 93f323e..2098ddc 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index/sql/9.1_plus/alter.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index/sql/9.1_plus/alter.sql
@@ -1,9 +1,11 @@
 {## Alter index to use cluster type ##}
 {% if data.indisclustered %}
+
 ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
     CLUSTER ON {{conn|qtIdent(data.name)}};
 {% endif %}
 {## Changes description ##}
 {% if data.description %}
+
 COMMENT ON INDEX {{conn|qtIdent(data.name)}}
     IS {{data.description|qtLiteral}};{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/js/table.js
index 562913b..0258ca7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/js/table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/js/table.js
@@ -265,7 +265,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
           coll_inherits: [],
           hastoasttable: true,
           toast_autovacuum_enabled: false,
-          autovacuum_enabled: false
+          autovacuum_enabled: false,
+          primary_key: []
        },
         // Default values!
         initialize: function(attrs, args) {
@@ -366,7 +367,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
             })
         },{
           id: 'fillfactor', label:'{{ _('Fill factor') }}', cell: 'integer',
-          type: 'int', mode: ['properties', 'create', 'edit'], min: 10, max: 100,
+          type: 'int', mode: ['create', 'edit'], min: 10, max: 100,
           disabled: 'inSchema',group: '{{ _('Advanced') }}'
         },{
           id: 'relhasoids', label:'{{ _('Has OIDs?') }}', cell: 'switch',
@@ -687,7 +688,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
         },{
           // Here we will create tab control for auto-vacuum
           type: 'nested', control: 'tab', group: '{{ _('Auto vacuum') }}',
-          mode: ['properties', 'edit', 'create'],
+          mode: ['edit', 'create'],
           schema: Backform.VacuumSettingsSchema
         },{
           id: 'relacl_str', label:'{{ _('Privileges') }}', cell: 'string',
@@ -706,7 +707,11 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
           group: '{{ _('Security') }}', mode: ['edit', 'create'],
           min_version: 90100, canAdd: true,
           canEdit: false, canDelete: true, control: 'unique-col-collection'
-        }],
+        },{
+          id: 'vacuum_settings_str', label: '{{ _('Storage Settings') }}',
+          type: 'multiline', group: '{{ _('Advanced') }}', mode: ['properties']
+        }
+        ],
         validate: function() {
           var err = {},
               changedAttrs = this.changed,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/create.sql
index 9dcbd43..5075404 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/create.sql
@@ -88,7 +88,6 @@ TABLESPACE {{ conn|qtIdent(data.spcname) }};
 
 ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
     OWNER to {{conn|qtIdent(data.relowner)}};
-
 {% endif %}
 {### Security Labels on Table ###}
 {% if data.seclabels and data.seclabels|length > 0 %}
@@ -96,20 +95,18 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
 {% for r in data.seclabels %}
 {{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.security_label, data.schema) }}
 {% endfor %}
-
 {% endif %}
 {###  ACL on Table ###}
 {% if data.relacl %}
+
 {% for priv in data.relacl %}
 {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}
 {% endfor %}
 {% endif %}
 {### SQL for COMMENT ###}
 {% if data.description %}
-
 COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
     IS {{data.description|qtLiteral}};
-
 {% endif %}
 {#===========================================#}
 {#====== MAIN TABLE TEMPLATE ENDS HERE ======#}
@@ -123,14 +120,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
 
 COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}}
     IS {{c.description|qtLiteral}};
-
 {% endif %}
 {###  Add variables to column ###}
 {% if c.attoptions and c.attoptions|length > 0 %}
 
 ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
     {{ VARIABLE.SET(conn, 'COLUMN', c.name, c.attoptions) }}
-
 {% endif %}
 {###  ACL ###}
 {% if c.attacl and c.attacl|length > 0 %}
@@ -138,7 +133,6 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
 {% for priv in c.attacl %}
     {{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }}
 {% endfor %}
-
 {% endif %}
 {###  Security Lables ###}
 {% if c.seclabels and c.seclabels|length > 0 %}
@@ -146,7 +140,6 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
 {% for r in c.seclabels %}
 {{ COLUMN_SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.security_label) }}
 {% endfor %}
-
 {% endif %}
 {% endfor %}
 {% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_relations.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_relations.sql
index 3e4840e..431ee88 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_relations.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_relations.sql
@@ -2,8 +2,5 @@ SELECT c.oid, quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS like_relati
 FROM pg_class c, pg_namespace n
 WHERE c.relnamespace=n.oid
 AND
--- before PG 9.2
--- c.relkind IN ('r')
--- PG 9.2
 c.relkind IN ('r', 'v', 'f')
 ORDER BY 1;
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
index d819c98..99727c9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
@@ -22,7 +22,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
 		WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt,
 	(CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence,
 	substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor,
-	substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') AS autovacuum_enabled,
+	(CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true')
+	  THEN true ELSE false END) AS autovacuum_enabled,
 	substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold,
 	substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_vacuum_scale_factor,
 	substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold,
@@ -32,7 +33,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
 	substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age,
 	substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age,
 	substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age,
-	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') AS toast_autovacuum_enabled,
+	(CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') =  'true')
+	  THEN true ELSE false END) AS toast_autovacuum_enabled,
 	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold,
 	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.][0-9]*)') AS toast_autovacuum_vacuum_scale_factor,
 	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold,
@@ -42,6 +44,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
 	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age,
 	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age,
 	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age,
+	array_to_string(rel.reloptions, ',') AS table_vacuum_settings_str,
+	array_to_string(tst.reloptions, ',') AS toast_table_vacuum_settings_str,
 	rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype, typ.typname,
 	(CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable,
     -- Added for pgAdmin4
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/update.sql
index 904e451..270c6c9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/update.sql
@@ -137,7 +137,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET (
 ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET (
 {% set flag = true %}
 {% endif %}
-    {{opt.name}} = {{opt.value}}{% endif %}
+    toast.{{opt.name}} = {{opt.value}}{% endif %}
 {% if loop.index == data.vacuum_toast.changed|length and (flag or (data.toast_autovacuum_enabled and o_data.toast_autovacuum_enabled == false) or (data.toast_autovacuum_enabled == false and o_data.toast_autovacuum_enabled))%}
 
 );
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/acl.sql
index e231ecc..56f1f76 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/acl.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/acl.sql
@@ -26,7 +26,7 @@ FROM
           LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'
           LEFT OUTER JOIN pg_class tst ON tst.oid = rel.reltoastrelid
           LEFT JOIN pg_type typ ON rel.reloftype=typ.oid
-        WHERE rel.relkind IN ('r','s','t','f') AND rel.relnamespace = {{ scid }}::oid
+        WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
             AND rel.oid = {{ tid }}::oid
     ) acl,
     (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable
@@ -37,7 +37,7 @@ FROM
           LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'
           LEFT OUTER JOIN pg_class tst ON tst.oid = rel.reltoastrelid
           LEFT JOIN pg_type typ ON rel.reloftype=typ.oid
-        WHERE rel.relkind IN ('r','s','t','f') AND rel.relnamespace = {{ scid }}::oid
+        WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
             AND rel.oid = {{ tid }}::oid
         ) a) d
     ) d
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/create.sql
index 5b786ef..5075404 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/create.sql
@@ -98,13 +98,13 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
 {% endif %}
 {###  ACL on Table ###}
 {% if data.relacl %}
+
 {% for priv in data.relacl %}
 {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}
 {% endfor %}
 {% endif %}
 {### SQL for COMMENT ###}
 {% if data.description %}
-
 COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
     IS {{data.description|qtLiteral}};
 {% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oid.sql
index c0d8d58..e9dc772 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oid.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oid.sql
@@ -1,5 +1,5 @@
 SELECT rel.oid as tid
 FROM pg_class rel
-WHERE rel.relkind IN ('r','s','t','f')
+WHERE rel.relkind IN ('r','s','t')
 AND rel.relnamespace = {{ scid }}::oid
 AND rel.relname = {{data.name|qtLiteral}}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/properties.sql
index 6e850bc..99727c9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/properties.sql
@@ -16,10 +16,10 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
     JOIN pg_namespace n ON n.oid=c.relnamespace
     WHERE i.inhrelid = rel.oid ORDER BY inhseqno)) AS coll_inherits,
   (SELECT count(*)
-    FROM pg_inherits i
+		FROM pg_inherits i
       JOIN pg_class c ON c.oid = i.inhparent
       JOIN pg_namespace n ON n.oid=c.relnamespace
-    WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt,
+		WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt,
 	(CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence,
 	substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor,
 	(CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true')
@@ -44,11 +44,13 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
 	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age,
 	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age,
 	substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age,
+	array_to_string(rel.reloptions, ',') AS table_vacuum_settings_str,
+	array_to_string(tst.reloptions, ',') AS toast_table_vacuum_settings_str,
 	rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype, typ.typname,
 	(CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable,
     -- Added for pgAdmin4
 	(CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean  THEN true ELSE false END) AS autovacuum_custom,
-	(CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true')  OR rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum,
+	(CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean  AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum,
 
 	(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels,
 	(CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/update.sql
index 904e451..270c6c9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/update.sql
@@ -137,7 +137,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET (
 ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET (
 {% set flag = true %}
 {% endif %}
-    {{opt.name}} = {{opt.value}}{% endif %}
+    toast.{{opt.name}} = {{opt.value}}{% endif %}
 {% if loop.index == data.vacuum_toast.changed|length and (flag or (data.toast_autovacuum_enabled and o_data.toast_autovacuum_enabled == false) or (data.toast_autovacuum_enabled == false and o_data.toast_autovacuum_enabled))%}
 
 );
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger.js
index b7946d3..bd22795 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger.js
@@ -344,7 +344,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
                 return m.inSchemaWithModelCheck.apply(this, [m]);
             }
         },{
-            id: 'evnt_turncate', label:'{{ _('TURNCATE') }}',
+            id: 'evnt_turncate', label:'{{ _('TRUNCATE') }}',
             type: 'switch', group: '{{ _('Events') }}',
             disabled: function(m) {
             var is_constraint_trigger = m.get('is_constraint_trigger'),
@@ -374,7 +374,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
             mode: ['create', 'edit', 'properties'],
             control: 'sql-field', visible: true, group: '{{ _('Definition') }}'
         },{
-            id: 'columns', label: '{{ _('Columns') }}',
+            id: 'columns', label: '{{ _('Columns') }}', url: 'nodes',
             type: 'collection', control: 'multi-select-ajax',
             deps: ['evnt_update'], node: 'column', group: '{{ _('Definition') }}',
             model: pgBrowser.Node.Model.extend({
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
index 183ec2f..dc18a31 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
@@ -6,6 +6,10 @@
 GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }};
 {% endif %}
 {% if with_grant_privs %}
+{% if privs %}
+{# This empty if is to add new line in between #}
+
+{% endif %}
 GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
 {% endif %}
 {%- endmacro %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/js/schema.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/js/schema.js
index d012dbc..587d5f2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/js/schema.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/js/schema.js
@@ -131,7 +131,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
     var VacuumSettingsSchema = Backform.VacuumSettingsSchema =
      [{
             id: 'autovacuum_custom', label: '{{ _("Custom auto-vacuum?") }}',
-              group: '{{ _("Table") }}', mode: ['properties', 'edit', 'create'],
+              group: '{{ _("Table") }}', mode: ['edit', 'create'],
               type: 'switch',
               disabled: function(m) {
                 if(!m.top.inSchema.apply(this, [m])) {
@@ -141,7 +141,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
               }
           },{
               id: 'autovacuum_enabled', label: '{{ _("Enabled?") }}',
-              group: '{{ _("Table") }}', mode: ['properties', 'edit', 'create'],
+              group: '{{ _("Table") }}', mode: ['edit', 'create'],
               type: 'switch',
               deps: ['autovacuum_custom'],
               disabled: function(m) {
@@ -160,7 +160,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
               id: 'vacuum_table', label: '{{ _("Vacuum Table") }}',
               model: Backform.VacuumTableModel, editable: false, type: 'collection',
               canEdit: true, group: '{{ _("Table") }}',
-              mode: ['properties', 'edit', 'create'], url: 'get_table_vacuum',
+              mode: ['edit', 'create'], url: 'get_table_vacuum',
               control: Backform.VacuumCollectionControl.extend({
                 grid_columns :[
                   {
@@ -183,7 +183,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
               deps: ['autovacuum_enabled']
           },{
               id: 'toast_autovacuum', label: '{{ _("Custom auto-vaccum?") }}',
-              group: '{{ _("Toast Table") }}', mode: ['properties', 'edit', 'create'],
+              group: '{{ _("Toast Table") }}', mode: ['edit', 'create'],
               type: 'switch',
               disabled: function(m) {
                 // We need to check additional condition to toggle enable/disable
@@ -191,15 +191,15 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
                 if(!m.top.inSchema.apply(this, [m]) && m.isNew()) {
                   return false;
                 } else if(!m.top.inSchema.apply(this, [m]) &&
-                    m.get('toast_autovacuum_enabled') === true ||
-                    m.top.get('hastoasttable') === true) {
+                    (m.get('toast_autovacuum_enabled') === true ||
+                    m.top.get('hastoasttable') === true)) {
                   return false;
                 }
                 return true;
               }
           },{
               id: 'toast_autovacuum_enabled', label: '{{ _("Enabled?") }}',
-              group: '{{ _("Toast Table") }}', mode: ['properties', 'edit', 'create'],
+              group: '{{ _("Toast Table") }}', mode: ['edit', 'create'],
               type: 'switch',
               deps:['toast_autovacuum'],
               disabled: function(m) {
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to