mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Include the WHERE clause on EXCLUDE constraints in RE-SQL. Fixes #3726
This commit is contained in:
@@ -764,8 +764,8 @@ define('pgadmin.node.exclusion_constraint', [
|
||||
}
|
||||
},
|
||||
},{
|
||||
id: 'constraint', label: gettext('Constraint'), cell: 'string',
|
||||
type: 'multiline', mode: ['create', 'edit'], editable: false,
|
||||
id: 'indconstraint', label: gettext('Constraint'), cell: 'string',
|
||||
type: 'multiline', mode: ['create', 'edit', 'properties'], editable: false,
|
||||
group: gettext('Definition'), disabled: function(m) {
|
||||
return ((_.has(m, 'handler') &&
|
||||
!_.isUndefined(m.handler) &&
|
||||
|
||||
@@ -59,6 +59,7 @@ class ExclusionConstraintAddTestCase(BaseTestGenerator):
|
||||
"columns": [
|
||||
{"column": "id", "sort_order": False, "nulls": False,
|
||||
"operator": "="}],
|
||||
"indconstraint": "(1=2)",
|
||||
"include": ["name"]
|
||||
}
|
||||
response = self.tester.post(
|
||||
|
||||
@@ -8,12 +8,12 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
|
||||
|
||||
WITH (FILLFACTOR={{data.fillfactor}}){% endif %}{% if data.spcname and data.spcname != "pg_default" %}
|
||||
|
||||
USING INDEX TABLESPACE {{ conn|qtIdent(data.spcname) }}{% endif %}
|
||||
USING INDEX TABLESPACE {{ conn|qtIdent(data.spcname) }}{% endif %}{% if data.indconstraint %}
|
||||
WHERE ({{data.indconstraint}}){% endif%}
|
||||
{% if data.condeferrable %}
|
||||
|
||||
DEFERRABLE{% if data.condeferred %}
|
||||
INITIALLY DEFERRED{% endif%}
|
||||
{% endif%}{% if data.constraint %} WHERE ({{data.constraint}}){% endif%};
|
||||
INITIALLY DEFERRED{% endif%}{% endif%};
|
||||
{% if data.comment and data.name %}
|
||||
|
||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
||||
|
||||
@@ -15,7 +15,8 @@ SELECT cls.oid,
|
||||
END AS comment,
|
||||
condeferrable,
|
||||
condeferred,
|
||||
substring(array_to_string(cls.reloptions, ',') from 'fillfactor=([0-9]*)') AS fillfactor
|
||||
substring(array_to_string(cls.reloptions, ',') from 'fillfactor=([0-9]*)') AS fillfactor,
|
||||
pg_get_expr(idx.indpred, idx.indrelid) AS indconstraint
|
||||
FROM pg_index idx
|
||||
JOIN pg_class cls ON cls.oid=indexrelid
|
||||
JOIN pg_class tab ON tab.oid=indrelid
|
||||
|
||||
@@ -4,14 +4,15 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
|
||||
{% endif %}{{ conn|qtIdent(col.column)}}{% if col.oper_class and col.oper_class != '' %} {{col.oper_class}}{% endif%}{% if col.order is defined and col.is_sort_nulls_applicable %}{% if col.order %} ASC{% else %} DESC{% endif %} NULLS{% endif %} {% if col.nulls_order is defined and col.is_sort_nulls_applicable %}{% if col.nulls_order %}FIRST {% else %}LAST {% endif %}{% endif %}WITH {{col.operator}}{% endfor %}){% if data.fillfactor %}
|
||||
WITH (FILLFACTOR={{data.fillfactor}}){% endif %}{% if data.spcname and data.spcname != "pg_default" %}
|
||||
|
||||
USING INDEX TABLESPACE {{ conn|qtIdent(data.spcname) }}{% endif %}
|
||||
USING INDEX TABLESPACE {{ conn|qtIdent(data.spcname) }}{% endif %}{% if data.indconstraint %}
|
||||
|
||||
WHERE ({{data.indconstraint}}){% endif%}
|
||||
{% if data.condeferrable %}
|
||||
|
||||
DEFERRABLE{% if data.condeferred %}
|
||||
INITIALLY DEFERRED{% endif%}
|
||||
{% endif%}{% if data.constraint %} WHERE ({{data.constraint}}){% endif%};
|
||||
INITIALLY DEFERRED{% endif%}{% endif%};
|
||||
{% if data.comment and data.name %}
|
||||
|
||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
||||
IS {{ data.comment|qtLiteral }};
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -15,7 +15,8 @@ SELECT cls.oid,
|
||||
END AS comment,
|
||||
condeferrable,
|
||||
condeferred,
|
||||
substring(array_to_string(cls.reloptions, ',') from 'fillfactor=([0-9]*)') AS fillfactor
|
||||
substring(array_to_string(cls.reloptions, ',') from 'fillfactor=([0-9]*)') AS fillfactor,
|
||||
pg_get_expr(idx.indpred, idx.indrelid) AS indconstraint
|
||||
FROM pg_index idx
|
||||
JOIN pg_class cls ON cls.oid=indexrelid
|
||||
JOIN pg_class tab ON tab.oid=indrelid
|
||||
|
||||
Reference in New Issue
Block a user