Hi,
PFA patch for table node (version 8.1). apply this patch on version 7
patch. Not all issue are fixed in this patch. Murtuza will be sending
version 8.2 witch will have resolution for remaining issues. Apply version
8.2 patch on version 8.1
--
*Harshal Dhumal*
*Software Engineer *
EenterpriseDB <http://www.enterprisedb.com>
On Tue, May 17, 2016 at 10:12 PM, Sanket Mehta <
[email protected]> wrote:
> Hi Harshal,
>
>
> Below are my review comments:
>
> I got below warning when I tried to apply the patch for table node as
> mentioned below:
>
> Table creation:
>
> - Trailing white spaces warnings
>
> $ git apply
> /projects/patches/pgadmin4/Table/table_14_May_V6.patch
>
> /projects/patches/pgadmin4/Table/table_14_May_V6.patch:6008: trailing
> whitespace.
> return false;
>
> /projects/patches/pgadmin4/Table/table_14_May_V6.patch:6016: trailing
> whitespace.
> return false;
> warning: 2 lines add whitespace errors.
>
Fixed (These were introduced due to rules node.)
>
> - In Table creation dialog, while adding a new primary key, it does
> not allow to change the tablespace to empty. (which is not the case in case
> of tablespace in table)
>
> Fixed
>
> - In Table creation dialog, while adding a new column, data type and
> name field must be mandatory. otherwise while clicking on save it gives
> below error
>
> File
> "/projects/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py",
> line 1319, in _parse_format_columns
> c['cltype'] = self._cltype_formatter(c['cltype'])
> KeyError: 'cltype
>
Fixed
>
> - In Table creation dialog, While adding a new column, in primary
> check box is needed to click twice in order to check it. Ideally it should
> be checked by only one click.
>
> This is Backgrid behaviour.
>
> - In Table creation dialog, While adding a new column, primary key
> should not be allowed to added unless user has provided name and data type
> for at least one column.
>
> Fixed
>
> - currently if user has clicked on add column button and immediately
> click on add primary key button, it will add a row in primary key data grid
>
> Fixed
>
> - When delete table/drop cascade is apply on any table, i got a
> javascript error as mentioned below
>
> node.js:94 Uncaught TypeError: self.canDrop.apply is not
> a function
>
Already fixed in other commit.
>
> - Once the above error generated, every time user tries to open a
> context menu by right clicking on any existing table, that same error comes
>
> Already fixed in other commit.
>
> - In table creation dialog, if table is inherited from another table,
> if a new primary key is added manually there, the create sql will not have
> an entry for primary key
>
> Fixed
>
> - In table creation dialog, if primary key check box is checked while
> adding the row, a new row is added in primary key datagrid but unchecking
> the primary key checkbox from column datagrid, does not removes that row
> from primary key data grid.
>
> Fixed.
>
> - In AutoVacuum tab, if user provides any invalid value to any
> parameter, then a error message should be prompted, only background color
> change would not tell user to change the value.
>
> Expected behaviour.
>
> - In table creation dialog, security label are not being added.
> javascript error is coming as mentioned below:
> {"success": 0, "info": "", "result": null, "data": null, "errormsg":
> "can't adapt type 'Undefined'"}
>
> Fixed
>
> - In Table creation dialog, while adding foreign key, in action tab.
> if user click on 'x' button in "on update" or "on delete" select2 control,
> it gives error "Uncaught SyntaxError: Unexpected end of input"
>
> Fixed
>
> - In Table creation dialog, while adding a check constraint,
> "validated" button does not work properly
>
> Fixed.
>
> - After successfully creation of table, "table name cannot be empty"
> error is not getting cleared.
>
> Not reproducible.
>
> - In Table creation dialog, if user has added an empty column without
> entering its name or type and trying to add check constraint, it will add
> an empty constraint
>
> Expected behaviour (Columns are not mandatory for check constrains)
>
> - In Table creation dialog, while adding an exclude constraint, for
> "character varying" column type, no operators are being listed
>
> There are no operators for character varying data type.
>
> - In Table creation dialog, while adding an exclude constraint, below
> mentioned error comes if user removes operator class by clicking 'x' on
> that control Uncaught TypeError: Cannot read property 'id' of undefined
>
> TODO
>
> - In Table creation dialog, SQL is not getting generated for exclude
> constraint
>
> Fixed
>
> - In Table creation dialog, schema should be prefixed with table name
> in "of type" control
>
> Fixed
>
> - In Table creation dialog, while adding privileges, it always shows
> default privileges even if user has selected different privileges. (This
> works fine once user edit the privileges in edit table mode and shows only
> those privileges which user selects). Ashesh, please confirm the behaviour.
>
> Privileges are set correctly. Only it shows in incorrect order.
> Table edit mode:
>
> - If in edit mode, any constraint is already having any comment, then
> remove it. It will not create the SQL for the same.
>
>
Fixed
>
> - Changing Schema will give server error
>
> This is generic issue for each node.
> Column Creation:
>
> - Save button is enabled by default
> - Data type validation is not provided. Save button is enabled just
> after providing column name
> - Length field limitation is not provided. (i.e. for numeric type,
> length should be allowed greater than 1000)
>
> Exclusion constraint creation:
>
> - Access method should not be allowed to be empty. (currently by
> clicking 'x' will remove the selection in it)
>
> Access method is optional.
> Index creation:
>
> - No error message for name field when empty
> - No error message when column name is not provided while adding a
> column in index
> - While adding a column if no name is provided, "None" appears in SQL
> tab which will give error on OK button click
> - when comment is provided while creation, it gives error saying index
> does not exists. because schema name is not added before it.
>
> Rule creation:
>
> - Name is empty error does not come till user enters something in
> definition tab
> - DO INSTEAD button does not make any difference to SQL (it works in
> edit mode)
>
> Rule edit mode:
>
> - Add comment in edit mode, check the SQL in sql tab. Now come back to
> general tab and removes comment and check the sql tab again.
> SQL for comment is still there with empty string as comment
>
> Trigger Creation:
>
> - SQL is not proper when creating a trigger. "()" should be appended
> to function name in SQL.
> It gives error while creating a trigger
> - "+" sign is visible in browser tree in front of trigger. either On
> expanding trigger, it should show the trigger function name or that "+"
> sign should not appear
>
> Trigger edit node:
>
> - On removing comment, nothing happens. No sql is being created.
> Comment is still there in properties.
>
>
>
> Regards,
> Sanket Mehta
> Sr Software engineer
> Enterprisedb
>
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 c561159..9fcafe8 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
@@ -581,7 +581,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
seclabels = []
for seclbls in column['seclabels']:
k, v = seclbls.split('=')
- seclabels.append({'provider': k, 'security_label': v})
+ seclabels.append({'provider': k, 'label': v})
column['seclabels'] = seclabels
@@ -945,7 +945,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
seclabels = []
for seclbls in data['seclabels']:
k, v = seclbls.split('=')
- seclabels.append({'provider': k, 'security_label': v})
+ seclabels.append({'provider': k, 'label': v})
data['seclabels'] = seclabels
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/templates/check_constraint/js/check_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/templates/check_constraint/js/check_constraint.js
index 6dbaac6..afc5ba9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/templates/check_constraint/js/check_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/templates/check_constraint/js/check_constraint.js
@@ -136,7 +136,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
!_.isUndefined(m.get('oid'))) || (_.isFunction(m.isNew) && !m.isNew()));
}
},{
- id: 'convalidated', label: "{{ _("Validated?") }}", type: 'switch', cell:
+ id: 'convalidated', label: "{{ _("Don't validate") }}", type: 'switch', cell:
'boolean', group: '{{ _('Definition') }}', min_version: 90200,
disabled: function(m) {
if ((_.isFunction(m.isNew) && !m.isNew()) ||
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js
index d6b6acf..26335df 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js
@@ -156,6 +156,8 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
m = self.model,
col_type = self.model.get('col_type');
+ self.column.set('options', []);
+
if (url && !_.isUndefined(col_type) && !_.isNull(col_type) && col_type != '') {
var node = this.column.get('schema_node'),
eventHandler = m.top || m,
@@ -194,25 +196,11 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
} else {
self.column.set('options', data);
}
- } else {
- self.column.set('options', []);
}
}
})
}
- ],
- validate: function() {
- var err = {},
- errmsg = null,
- data = this.toJSON();
-
- if (_.isUndefined(data.operator) ||
- _.isNull(data.operator) ||
- String(data.operator).replace(/^\s+|\s+$/g, '') == '') {
- return '{{ _('Please specify value for operator.')}}';
- }
- return null;
- }
+ ]
});
var ExclusionConstraintColumnControl = Backform.ExclusionConstraintColumnControl =
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
index a47f3ad..06d6b53 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
@@ -879,7 +879,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
},{
id: 'confupdtype', label:'{{ _('On update') }}',
type:"select2", group: '{{ _('Action') }}', mode: ['edit','create'],
- select2:{width:"50%"},
+ select2:{width:"50%", allowClear: false},
options: [
{label: "NO ACTION", value: "a"},
{label: "RESTRICT", value: "r"},
@@ -899,7 +899,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
},{
id: 'confdeltype', label:'{{ _('On delete') }}',
type:"select2", group: '{{ _('Action') }}', mode: ['edit','create'],
- select2:{width:"50%"},
+ select2:{width:"50%", allowClear: false},
options: [
{label: "NO ACTION", value: "a"},
{label: "RESTRICT", value: "r"},
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/templates/index_constraint/js/index_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/templates/index_constraint/js/index_constraint.js
index d6317ba..c5afe3a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/templates/index_constraint/js/index_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/templates/index_constraint/js/index_constraint.js
@@ -149,9 +149,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
return Backgrid.StringCell.prototype.render.apply(this, arguments);
},
remove: function() {
- var tableCols = this.model.top.get('columns');
+ var tableCols = this.model.top.get('columns'),
+ primary_key_col = this.model.get('columns');
+
+ if (primary_key_col) {
+ primary_key_col.off('pgadmin:multicolumn:updated');
+ }
- this.model.get('columns').off('pgadmin:multicolumn:updated');
{% if node_type == 'primary_key' %}
this.stopListening(tableCols, 'remove' , self.resetColOptions);
this.stopListening(tableCols, 'change:name' , self.resetColOptions);
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js
index 715447f..29022a6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js
@@ -46,7 +46,7 @@ function($, _, S, pgAdmin, pgBrowser, CodeMirror) {
canDrop: function(itemData, item, data){
pgBrowser.Nodes['schema'].canChildDrop.apply(this, [itemData, item, data]);
if(itemData.label === '_RETURN')
- return false;
+ return false;
else {
return true;
}
@@ -54,7 +54,7 @@ function($, _, S, pgAdmin, pgBrowser, CodeMirror) {
canDropCascade: function(itemData, item, data){
pgBrowser.Nodes['schema'].canChildDrop.apply(this, [itemData, item, data]);
if(itemData.label === '_RETURN')
- return false;
+ return false;
else {
return true;
}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.1_plus/update.sql
index 608cbf9..57d81c7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.1_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.1_plus/update.sql
@@ -1,4 +1,4 @@
-{% if data.comment and data.comment != o_data.comment %}
+{% if data.comment is defined and data.comment != o_data.comment %}
COMMENT ON CONSTRAINT {{ conn|qtIdent(o_data.name) }} ON {{ conn|qtIdent(o_data.nspname, o_data.relname) }}
IS {{ data.comment|qtLiteral }};
{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql
index 000047d..6c27923 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql
@@ -6,7 +6,7 @@ ALTER TABLE {{ conn|qtIdent(o_data.nspname, o_data.relname) }}
ALTER TABLE {{ conn|qtIdent(o_data.nspname, o_data.relname) }}
VALIDATE CONSTRAINT {{ conn|qtIdent(data.name) }};{% endif -%}
-{% if data.comment and data.comment != o_data.comment %}
+{% if data.comment is defined and data.comment != o_data.comment %}
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(o_data.nspname, o_data.relname) }}
IS {{ data.comment|qtLiteral }};{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/create.sql
index 2b0d78f..51eea52 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/create.sql
@@ -21,7 +21,7 @@ COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}}
{### Add variables to column ###}
{% if data.attoptions %}
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
-{{ VARIABLE.SET(conn, 'COLUMN', data.name, data.attoptions) }}
+ {{ VARIABLE.SET(conn, 'COLUMN', data.name, data.attoptions) }}
{% endif %}
{### ACL ###}
@@ -33,6 +33,6 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
{### Security Lables ###}
{% if data.seclabels %}
{% for r in data.seclabels %}
-{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.security_label) }}
+{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
{% endfor %}
{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql
index 4c902c5..a36c6fc 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql
@@ -52,15 +52,15 @@ COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}}
{% set variables = data.attoptions %}
{% if 'deleted' in variables and variables.deleted|length > 0 %}
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
-{{ VARIABLE.UNSET(conn, 'COLUMN', data.name, variables.deleted) }}
+ {{ VARIABLE.UNSET(conn, 'COLUMN', data.name, variables.deleted) }}
{% endif %}
{% if 'added' in variables and variables.added|length > 0 %}
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
-{{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.added) }}
+ {{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.added) }}
{% endif %}
{% if 'changed' in variables and variables.changed|length > 0 %}
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
-{{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.changed) }}
+ {{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.changed) }}
{% endif %}
{% endif %}
@@ -95,12 +95,12 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
{% endif %}
{% if 'added' in seclabels and seclabels.added|length > 0 %}
{% for r in seclabels.added %}
-{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.security_label) }}
+{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
{% endfor %}
{% endif %}
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
{% for r in seclabels.changed %}
-{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.security_label) }}
+{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
{% endfor %}
{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/create.sql
index 2b0d78f..51eea52 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/create.sql
@@ -21,7 +21,7 @@ COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}}
{### Add variables to column ###}
{% if data.attoptions %}
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
-{{ VARIABLE.SET(conn, 'COLUMN', data.name, data.attoptions) }}
+ {{ VARIABLE.SET(conn, 'COLUMN', data.name, data.attoptions) }}
{% endif %}
{### ACL ###}
@@ -33,6 +33,6 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
{### Security Lables ###}
{% if data.seclabels %}
{% for r in data.seclabels %}
-{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.security_label) }}
+{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
{% endfor %}
{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
index 83f21d4..bcfb90c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
@@ -52,15 +52,15 @@ COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}}
{% set variables = data.attoptions %}
{% if 'deleted' in variables and variables.deleted|length > 0 %}
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
-{{ VARIABLE.UNSET(conn, 'COLUMN', data.name, variables.deleted) }}
+ {{ VARIABLE.UNSET(conn, 'COLUMN', data.name, variables.deleted) }}
{% endif %}
{% if 'added' in variables and variables.added|length > 0 %}
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
-{{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.added) }}
+ {{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.added) }}
{% endif %}
{% if 'changed' in variables and variables.changed|length > 0 %}
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
-{{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.changed) }}
+ {{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.changed) }}
{% endif %}
{% endif %}
{### Update column privileges ###}
@@ -94,12 +94,12 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
{% endif %}
{% if 'added' in seclabels and seclabels.added|length > 0 %}
{% for r in seclabels.added %}
-{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.security_label) }}
+{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
{% endfor %}
{% endif %}
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
{% for r in seclabels.changed %}
-{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.security_label) }}
+{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
{% endfor %}
{% endif %}
{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/update.sql
index d062e8b..4d70f21 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/update.sql
@@ -15,7 +15,7 @@ ALTER INDEX {{ conn|qtIdent(data.schema, data.name) }}
SET (FILLFACTOR={{ data.fillfactor }});
{% endif %}
{# ==== To update exclusion constraint comments ==== #}
-{% if data.comment and data.comment != o_data.comment %}
+{% if data.comment is defined and data.comment != o_data.comment %}
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
IS {{ data.comment|qtLiteral }};
{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/update.sql
index d062e8b..4d70f21 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/update.sql
@@ -15,7 +15,7 @@ ALTER INDEX {{ conn|qtIdent(data.schema, data.name) }}
SET (FILLFACTOR={{ data.fillfactor }});
{% endif %}
{# ==== To update exclusion constraint comments ==== #}
-{% if data.comment and data.comment != o_data.comment %}
+{% if data.comment is defined and data.comment != o_data.comment %}
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
IS {{ data.comment|qtLiteral }};
{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/update.sql
index a72f7e5..ee8f8a9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/update.sql
@@ -11,7 +11,7 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
VALIDATE CONSTRAINT {{ conn|qtIdent(data.name) }};
{% endif %}
{# ==== To update foreign key comments ==== #}
-{% if data.comment and data.comment != o_data.comment %}
+{% if data.comment is defined and data.comment != o_data.comment %}
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
IS {{ data.comment|qtLiteral }};
{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/update.sql
index af76d8e..6618532 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/update.sql
@@ -15,7 +15,7 @@ ALTER INDEX {{ conn|qtIdent(data.schema, data.name) }}
SET (FILLFACTOR={{ data.fillfactor }});
{% endif %}
{# ==== To update constraint comments ==== #}
-{% if data.comment and data.comment != o_data.comment %}
+{% if data.comment is defined and data.comment != o_data.comment %}
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
IS {{ data.comment|qtLiteral }};
{% endif %}
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 0258ca7..c1d8c4f 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
@@ -308,7 +308,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
},{
id: 'spcname', label:'{{ _('Tablespace') }}', cell: 'string', control: 'node-list-by-name',
type: 'text', mode: ['properties', 'create', 'edit'], node: 'tablespace',
- disabled: 'inSchema', filter: function(d) {
+ disabled: 'inSchema', select2:{allowClear:false},
+ filter: function(d) {
// If tablespace name is not "pg_global" then we need to exclude them
if(d && d.label.match(/pg_global/))
{
@@ -558,6 +559,20 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
removedCols = primary_key_column_coll.where({column:column_name});
if (removedCols.length > 0) {
primary_key_column_coll.remove(removedCols);
+ _.each(removedCols, function(m) {
+ m.destroy();
+ })
+ if (primary_key_column_coll.length == 0) {
+ setTimeout(function () {
+ // There will be only on primary key so remove the first one.
+ primary_key_coll.remove(primary_key_coll.first());
+ /* Ideally above line of code should be "primary_key_coll.reset()".
+ * But our custom DataCollection (extended from Backbone collection in datamodel.js)
+ * does not respond to reset event, it only supports add, remove, change events.
+ * And hence no custom event listeners/validators get called for reset event.
+ */
+ }, 10);
+ }
}
primary_key_column_coll.trigger('pgadmin:multicolumn:updated', primary_key_column_coll);
}
@@ -593,10 +608,12 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
columns : ['name', 'columns'],
canAdd: true,
canAddRow: function(m) {
- // Use can only add one primary key
+ // User can only add one primary key
+ var columns = m.get('columns');
+
return (m.get('primary_key') &&
m.get('primary_key').length < 1 &&
- m.get('columns').length > 0);
+ _.some(columns.pluck('name')));
}
},{
id: 'foreign_key', label: '{{ _('Foreign Key') }}',
@@ -609,8 +626,9 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
canAdd: true,
columns : ['name', 'columns'],
canAddRow: function(m) {
- // Use can only add if there are columns present
- return m.get('columns').length > 0;
+ // User can only add if there is at least one column with name.
+ var columns = m.get('columns');
+ return _.some(columns.pluck('name'));
}
},{
id: 'check_constraint', label: '{{ _('Check Constraint') }}',
@@ -621,11 +639,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
canEdit: true, canDelete: true,
control: 'unique-col-collection',
canAdd: true,
- columns : ['name', 'consrc'],
- canAddRow: function(m) {
- // Use can only add if there are columns present
- return m.get('columns').length > 0;
- }
+ columns : ['name', 'consrc']
},{
id: 'unique_constraint', label: '{{ _('Unique Constraint') }}',
model: pgBrowser.Nodes['unique_constraint'].model,
@@ -637,8 +651,9 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
columns : ['name', 'columns'],
canAdd: true,
canAddRow: function(m) {
- // Use can only add if there are columns present
- return m.get('columns').length > 0;
+ // User can only add if there is at least one column with name.
+ var columns = m.get('columns');
+ return _.some(columns.pluck('name'));
}
},{
id: 'exclude_constraint', label: '{{ _('Exclude Constraint') }}',
@@ -651,8 +666,9 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
columns : ['name', 'columns', 'constraint'],
canAdd: true,
canAddRow: function(m) {
- // Use can only add if there are columns present
- return m.get('columns').length > 0;
+ // User can only add if there is at least one column with name.
+ var columns = m.get('columns');
+ return _.some(columns.pluck('name'));
}
}]
}]
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 5075404..f45daa4 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
@@ -17,7 +17,7 @@
{% endif %}
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
{% if data.typname %}
- OF {{ conn|qtIdent(data.typname) }}
+ OF {{ data.typname }}
{% endif %}
{% if data.like_relation or data.coll_inherits or data.columns|length > 0 %}
(
@@ -45,16 +45,17 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data
{% endif %}
{{conn|qtIdent(c.name)}} {{c.cltype}}{% if c.attlen %}
({{c.attlen}}{% if c.attprecision%}, {{c.attprecision}}{% endif %}){% endif %}{% if c.hasSqrBracket %}
-[]{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval %} DEFAULT {{c.defval|qtLiteral}}{% endif %}
+[]{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval %} DEFAULT {{c.defval}}{% endif %}
{% endif %}
{% endfor %}
-{# Macro to render for constraints #}
-{% if data.primary_key|length > 0 %}
-{{CONSTRAINTS.PRIMARY_KEY(conn, data.primary_key[0])}}{% endif %}{% if data.unique_constraint|length > 0 %}
-{{CONSTRAINTS.UNIQUE(conn, data.unique_constraint)}}{% endif %}{% if data.foreign_key|length > 0 %}
-{{CONSTRAINTS.FOREIGN_KEY(conn, data.foreign_key)}}{% endif %}{% if data.check_constraint|length > 0 %}
-{{CONSTRAINTS.CHECK(conn, data.check_constraint)}}{% endif %}
{% endif %}
+{# Macro to render for constraints #}
+{% if data.primary_key|length > 0 %}{% if data.columns|length > 0 %},{% endif %}
+{{CONSTRAINTS.PRIMARY_KEY(conn, data.primary_key[0])}}{% endif %}{% if data.unique_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 %},{% endif %}
+{{CONSTRAINTS.UNIQUE(conn, data.unique_constraint)}}{% endif %}{% if data.foreign_key|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 %},{% endif %}
+{{CONSTRAINTS.FOREIGN_KEY(conn, data.foreign_key)}}{% endif %}{% if data.check_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 %},{% endif %}
+{{CONSTRAINTS.CHECK(conn, data.check_constraint)}}{% endif %}{% if data.exclude_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 %},{% endif %}
+{{CONSTRAINTS.EXCLUDE(conn, data.exclude_constraint)}}{% endif %}
{% if data.like_relation or data.coll_inherits or data.columns|length > 0 %}
)
@@ -93,7 +94,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
{% if data.seclabels and data.seclabels|length > 0 %}
{% for r in data.seclabels %}
-{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.security_label, data.schema) }}
+{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
{% endfor %}
{% endif %}
{### ACL on Table ###}
@@ -138,7 +139,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
{% if c.seclabels and c.seclabels|length > 0 %}
{% for r in c.seclabels %}
-{{ COLUMN_SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.security_label) }}
+{{ COLUMN_SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }}
{% endfor %}
{% endif %}
{% endfor %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_oftype.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_oftype.sql
index bca7f77..aed42f2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_oftype.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_oftype.sql
@@ -1,4 +1,5 @@
-SELECT t.oid, t.typname
+SELECT t.oid,
+ quote_ident(n.nspname)||'.'||quote_ident(t.typname) AS typname
FROM pg_type t, pg_namespace n
WHERE t.typtype='c' AND t.typnamespace=n.oid
AND NOT (n.nspname like 'pg_%' OR n.nspname='information_schema')
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 270c6c9..a97ac30 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
@@ -189,12 +189,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
{% endif %}
{% if 'added' in seclabels and seclabels.added|length > 0 %}
{% for r in seclabels.added %}
-{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.security_label, data.schema) }}
+{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
{% endfor %}
{% endif %}
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
{% for r in seclabels.changed %}
-{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.security_label, data.schema) }}
+{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
{% endfor %}
{% endif %}
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 5075404..f45daa4 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
@@ -17,7 +17,7 @@
{% endif %}
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
{% if data.typname %}
- OF {{ conn|qtIdent(data.typname) }}
+ OF {{ data.typname }}
{% endif %}
{% if data.like_relation or data.coll_inherits or data.columns|length > 0 %}
(
@@ -45,16 +45,17 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data
{% endif %}
{{conn|qtIdent(c.name)}} {{c.cltype}}{% if c.attlen %}
({{c.attlen}}{% if c.attprecision%}, {{c.attprecision}}{% endif %}){% endif %}{% if c.hasSqrBracket %}
-[]{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval %} DEFAULT {{c.defval|qtLiteral}}{% endif %}
+[]{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval %} DEFAULT {{c.defval}}{% endif %}
{% endif %}
{% endfor %}
-{# Macro to render for constraints #}
-{% if data.primary_key|length > 0 %}
-{{CONSTRAINTS.PRIMARY_KEY(conn, data.primary_key[0])}}{% endif %}{% if data.unique_constraint|length > 0 %}
-{{CONSTRAINTS.UNIQUE(conn, data.unique_constraint)}}{% endif %}{% if data.foreign_key|length > 0 %}
-{{CONSTRAINTS.FOREIGN_KEY(conn, data.foreign_key)}}{% endif %}{% if data.check_constraint|length > 0 %}
-{{CONSTRAINTS.CHECK(conn, data.check_constraint)}}{% endif %}
{% endif %}
+{# Macro to render for constraints #}
+{% if data.primary_key|length > 0 %}{% if data.columns|length > 0 %},{% endif %}
+{{CONSTRAINTS.PRIMARY_KEY(conn, data.primary_key[0])}}{% endif %}{% if data.unique_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 %},{% endif %}
+{{CONSTRAINTS.UNIQUE(conn, data.unique_constraint)}}{% endif %}{% if data.foreign_key|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 %},{% endif %}
+{{CONSTRAINTS.FOREIGN_KEY(conn, data.foreign_key)}}{% endif %}{% if data.check_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 %},{% endif %}
+{{CONSTRAINTS.CHECK(conn, data.check_constraint)}}{% endif %}{% if data.exclude_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 %},{% endif %}
+{{CONSTRAINTS.EXCLUDE(conn, data.exclude_constraint)}}{% endif %}
{% if data.like_relation or data.coll_inherits or data.columns|length > 0 %}
)
@@ -93,7 +94,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
{% if data.seclabels and data.seclabels|length > 0 %}
{% for r in data.seclabels %}
-{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.security_label, data.schema) }}
+{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
{% endfor %}
{% endif %}
{### ACL on Table ###}
@@ -138,7 +139,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
{% if c.seclabels and c.seclabels|length > 0 %}
{% for r in c.seclabels %}
-{{ COLUMN_SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.security_label) }}
+{{ COLUMN_SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }}
{% endfor %}
{% endif %}
{% endfor %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oftype.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oftype.sql
index bca7f77..aed42f2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oftype.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oftype.sql
@@ -1,4 +1,5 @@
-SELECT t.oid, t.typname
+SELECT t.oid,
+ quote_ident(n.nspname)||'.'||quote_ident(t.typname) AS typname
FROM pg_type t, pg_namespace n
WHERE t.typtype='c' AND t.typnamespace=n.oid
AND NOT (n.nspname like 'pg_%' OR n.nspname='information_schema')
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 270c6c9..a97ac30 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
@@ -189,12 +189,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
{% endif %}
{% if 'added' in seclabels and seclabels.added|length > 0 %}
{% for r in seclabels.added %}
-{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.security_label, data.schema) }}
+{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
{% endfor %}
{% endif %}
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
{% for r in seclabels.changed %}
-{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.security_label, data.schema) }}
+{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
{% endfor %}
{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/macros/constraints.macro b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/macros/constraints.macro
index 2ac429c..fe7389a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/macros/constraints.macro
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/macros/constraints.macro
@@ -4,7 +4,8 @@
{# CREATE MODE ONLY #}
{##########################}
{% macro PRIMARY_KEY(conn, data) -%}
-{% if data.columns|length > 0 %},
+{% if data.columns|length > 0 %}
+
{% if data.name %}CONSTRAINT {{conn|qtIdent(data.name)}} {% endif %}PRIMARY KEY ({% for c in data.columns%}
{% if loop.index != 1 %}, {% endif %}{{conn|qtIdent(c.column)}}{% endfor %}){% if data.fillfactor %}
@@ -19,7 +20,8 @@
{%- endmacro %}
{% macro UNIQUE(conn, unique_data) -%}
{% for data in unique_data %}
-{% if data.columns|length > 0 %},
+{% if data.columns|length > 0 %}{% if loop.index !=1 %},{% endif %}
+
{% if data.name %}CONSTRAINT {{conn|qtIdent(data.name)}} {% endif %}UNIQUE ({% for c in data.columns%}
{% if loop.index != 1 %}, {% endif %}{{conn|qtIdent(c.column)}}{% endfor %}){% if data.fillfactor %}
@@ -34,14 +36,15 @@
{% endfor %}
{%- endmacro %}
{% macro CHECK(conn, check_data) -%}
-{% for data in check_data %}
-,
+{% for data in check_data %}{% if loop.index !=1 %},{% endif %}
+
{% if data.name %}CONSTRAINT {{ conn|qtIdent(data.name) }} {% endif%}CHECK ({{ data.consrc }}){% if data.convalidated %}
NOT VALID{% endif %}{% if data.connoinherit %} NO INHERIT{% endif %}
{% endfor %}
{%- endmacro %}
{% macro FOREIGN_KEY(conn, foreign_key_data) -%}
-{% for data in foreign_key_data %},
+{% for data in foreign_key_data %}{% if loop.index != 1 %},{% endif %}
+
{% if data.name %}CONSTRAINT {{conn|qtIdent(data.name)}} {% endif %}FOREIGN KEY ({% for columnobj in data.columns %}{% if loop.index != 1 %}
, {% endif %}{{ conn|qtIdent(columnobj.local_column)}}{% endfor %})
REFERENCES {{ conn|qtIdent(data.remote_schema, data.remote_table) }} ({% for columnobj in data.columns %}{% if loop.index != 1 %}
@@ -71,7 +74,8 @@
{% endfor %}
{%- endmacro %}
{% macro EXCLUDE(conn, exclude_data) -%}
-{% for data in exclude_data %},
+{% for data in exclude_data %}{% if loop.index != 1 %},{% endif %}
+
{% if data.name %}CONSTRAINT {{ conn|qtIdent(data.name) }} {% endif%}EXCLUDE {% if data.amname and data.amname != '' %}USING {{data.amname}}{% endif %} ({% for col in data.columns %}{% if loop.index != 1 %},
{% endif %}{{ conn|qtIdent(col.column)}} {% if col.oper_class and col.oper_class != '' %}{{col.oper_class}} {% endif%}{% if col.order %}ASC{% else %}DESC{% endif %} NULLS {% if col.nulls_order %}FIRST{% else %}LAST{% endif %} WITH {{col.operator}}{% endfor %}){% if data.fillfactor %}
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers