From 7d6f077cf839a932fac72ddd6b51eddc91962605 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Mon, 26 Apr 2021 16:41:20 +0530 Subject: [PATCH] =?UTF-8?q?Fixed=20an=20issue=20where=20schema=20diff=20do?= =?UTF-8?q?es=20not=20create=20DROP=20DEFAULT=C2=A0statement=20for=20colum?= =?UTF-8?q?ns.=20Fixes=20#6377?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en_US/release_notes_5_3.rst | 1 + .../schemas/tables/templates/columns/sql/10_plus/update.sql | 2 +- .../schemas/tables/templates/columns/sql/9.2_plus/update.sql | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/en_US/release_notes_5_3.rst b/docs/en_US/release_notes_5_3.rst index 011cdd60d..2d637b7a4 100644 --- a/docs/en_US/release_notes_5_3.rst +++ b/docs/en_US/release_notes_5_3.rst @@ -19,4 +19,5 @@ Bug fixes | `Issue #6329 `_ - Fixed an issue where the wrong SQL is showing for the child partition tables. | `Issue #6341 `_ - Fixed an issue where CSV download quotes the numeric columns. +| `Issue #6377 `_ - Fixed an issue where schema diff does not create DROP DEFAULT statement for columns. | `Issue #6385 `_ - Ensure that Backup and Restore should work on shared servers. diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql index e698ed3b8..aa09f4ecc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql @@ -31,7 +31,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {### Drop column default value ###} -{% if data.defval is defined and data.defval == '' and data.defval != o_data.defval %} +{% if data.defval is defined and (data.defval == '' or data.defval is none) and data.defval != o_data.defval %} ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} DROP DEFAULT; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql index 8ca34d2cb..708a266dd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql @@ -31,7 +31,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {### Drop column default value ###} -{% if data.defval is defined and data.defval == '' and data.defval != o_data.defval %} +{% if data.defval is defined and (data.defval == '' or data.defval is none) and data.defval != o_data.defval %} ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} DROP DEFAULT;