Fix handling of CREATE TABLE OF <type>. Fixes #2534

This commit is contained in:
Harshal Dhumal 2017-07-07 16:34:33 +01:00 committed by Dave Page
parent 815c4b4c45
commit d151bdb4cd
2 changed files with 24 additions and 10 deletions

View File

@ -725,19 +725,33 @@ define('pgadmin.node.table', [
arg = undefined,
column_collection = self.model.get('columns');
if (!_.isUndefined(tbl_name) &&
if (!_.isUndefined(tbl_name) && !_.isNull(tbl_name) &&
tbl_name !== '' && column_collection.length !== 0) {
var msg = gettext('Changing of type table will clear columns collection');
alertify.confirm(msg, function (e) {
if (e) {
var title = gettext('Remove column definitions?'),
msg = gettext('Changing \'Of type\' will remove column definitions.');
alertify.confirm(title, msg, function (e) {
// User clicks Ok, lets clear columns collection
column_collection.reset();
} else {
return this;
column_collection.remove(
column_collection.filter(function(model) {
return true;
}
)
);
},
function() {
setTimeout(function() {
self.model.set('typname', null);
}, 10)
}
});
);
} else if (!_.isUndefined(tbl_name) && tbl_name === '') {
column_collection.reset();
column_collection.remove(
column_collection.filter(function(model) {
return true;
}
)
);
}
// Run Ajax now to fetch columns

View File

@ -18,7 +18,7 @@
{% endif %}
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
{% if data.typname %}
OF {{ conn|qtTypeIdent(data.typname) }}
OF {{ data.typname }}
{% endif %}
{% if data.like_relation or data.coll_inherits or 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 or data.exclude_constraint|length > 0 %}
(