Ensure invalid options can't be selected on triggers on views. Fixes #2945

This commit is contained in:
Khushboo Vashi 2018-01-03 14:32:00 +00:00 committed by Dave Page
parent 90629da524
commit 49dfd6fe31
2 changed files with 6 additions and 7 deletions

View File

@ -7,7 +7,7 @@ SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THE
{% if datlastsysoid %}
(CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger,
{% endif %}
(CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constarint,
(CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger,
(CASE WHEN tgenabled = 'O' THEN true ElSE false END) AS is_enable_trigger
FROM pg_trigger t
JOIN pg_class cl ON cl.oid=tgrelid

View File

@ -249,8 +249,9 @@ define('pgadmin.node.trigger', [
group: gettext('Definition'),
disabled: function(m) {
// Disabled if table is a partitioned table.
if (_.has(m, 'node_info') && _.has(m.node_info, 'table') &&
_.has(m.node_info.table, 'is_partitioned') && m.node_info.table.is_partitioned)
if ((_.has(m, 'node_info') && _.has(m.node_info, 'table') &&
_.has(m.node_info.table, 'is_partitioned') && m.node_info.table.is_partitioned) ||
_.indexOf(Object.keys(m.node_info), 'view') != -1)
{
setTimeout(function(){
m.set('is_constraint_trigger', false);
@ -258,6 +259,8 @@ define('pgadmin.node.trigger', [
return true;
}
return m.inSchemaWithModelCheck.apply(this, [m]);
}
},{
id: 'tgdeferrable', label: gettext('Deferrable?'),
@ -486,10 +489,6 @@ define('pgadmin.node.trigger', [
},{
id: 'is_sys_trigger', label: gettext('System trigger?'), cell: 'string',
type: 'switch', disabled: 'inSchemaWithModelCheck', mode: ['properties']
},{
id: 'is_constarint', label: gettext('Constraint?'), cell: 'string',
type: 'switch', disabled: 'inSchemaWithModelCheck', mode: ['properties'],
group: gettext('Definition')
},{
id: 'description', label: gettext('Comment'), cell: 'string',
type: 'multiline', mode: ['properties', 'create', 'edit'],