From d548a5bc504fb0a1bb24a7da1dad736033d48d4c Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Fri, 25 Mar 2022 16:39:20 +0530 Subject: [PATCH] Fixed schema diff issue in which the option 'null' doesn't appear in the DDL statement for the foreign table. Fixes #7265 --- docs/en_US/release_notes_6_8.rst | 1 + .../templates/foreign_tables/sql/9.2_plus/create.sql | 4 ++-- .../templates/foreign_tables/sql/9.2_plus/update.sql | 12 ++++++------ .../templates/foreign_tables/sql/9.5_plus/create.sql | 4 ++-- .../sql/9.5_plus/foreign_table_schema_diff.sql | 4 ++-- .../templates/foreign_tables/sql/9.5_plus/update.sql | 12 ++++++------ .../templates/foreign_tables/sql/default/create.sql | 2 +- .../templates/foreign_tables/sql/default/update.sql | 6 +++--- 8 files changed, 23 insertions(+), 22 deletions(-) diff --git a/docs/en_US/release_notes_6_8.rst b/docs/en_US/release_notes_6_8.rst index 89db80062..29f644913 100644 --- a/docs/en_US/release_notes_6_8.rst +++ b/docs/en_US/release_notes_6_8.rst @@ -25,5 +25,6 @@ Bug fixes | `Issue #7238 `_ - Fixed an issue where foreign key is not removed even if the referred table is removed in ERD. | `Issue #7257 `_ - Support running the container under OpenShift with alternate UIDs. | `Issue #7261 `_ - Correct typo in the documentation. + | `Issue #7265 `_ - Fixed schema diff issue in which the option 'null' doesn't appear in the DDL statement for the foreign table. | `Issue #7267 `_ - Fixed an issue where unexpected error messages are displayed when users change the language via preferences. | `Issue #7269 `_ - Ensure that pgAdmin4 should work with latest jinja2 version. diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql index dd5fd7f1a..0cd8fd9b4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql @@ -5,7 +5,7 @@ CREATE FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}( {% if data.columns %} {% for c in data.columns %} {{conn|qtIdent(c.attname)}} {% if is_sql %}{{ c.fulltype }}{% else %}{{c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}{% endif %}{% if c.coloptions %} -{% for o in c.coloptions %}{% if o.option and o.value %} +{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} {% endfor %}{% endif %}{% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %}{% if c.typdefault is defined and c.typdefault is not none %} @@ -18,7 +18,7 @@ CREATE FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}( SERVER {{ conn|qtIdent(data.ftsrvname) }}{% if data.ftoptions %} {% for o in data.ftoptions %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} {% endfor %}{% endif %}; {% if data.owner %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql index eedbd338e..a8deaa634 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql @@ -25,7 +25,7 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ADD COLUMN {{conn|qtIdent(c.attname)}} {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %} {% if c.coloptions %} -{% for o in c.coloptions %}{% if o.option and o.value %} +{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} {% endfor %}{% endif %} {% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %} @@ -70,13 +70,13 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} {% endif %} {% endfor %} {% for o in c.coloptions_updated.added %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} {% if loop.first %}ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (ADD {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} {% endif %} {% endfor %} {% for o in c.coloptions_updated.changed %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} {% if loop.first %}ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (SET {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} {% endif %} @@ -98,21 +98,21 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} {% endif -%} {% if data.ftoptions %} {% for o in data.ftoptions.deleted %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS ( DROP {{o.option}}); {% endif %} {% endfor %} {% for o in data.ftoptions.added %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}}); {% endif %} {% endfor %} {% for o in data.ftoptions.changed %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS (SET {{o.option}} {{o.value|qtLiteral}}); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql index f134883fd..6cbaafb5b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql @@ -8,7 +8,7 @@ CREATE FOREIGN TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ c {% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} {% if is_columns.append('1') %}{% endif %} {{conn|qtIdent(c.attname)}} {% if is_sql %}{{ c.fulltype }}{% else %}{{c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}{% endif %}{% if c.coloptions %} -{% for o in c.coloptions %}{% if o.option and o.value %} +{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} {% endfor %}{% endif %} {% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %} @@ -27,7 +27,7 @@ CREATE FOREIGN TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ c SERVER {{ conn|qtIdent(data.ftsrvname) }}{% if data.ftoptions %} {% for o in data.ftoptions %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} {% endfor %}{% endif %}; {% if data.owner %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/foreign_table_schema_diff.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/foreign_table_schema_diff.sql index 21c66260c..29596970d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/foreign_table_schema_diff.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/foreign_table_schema_diff.sql @@ -17,7 +17,7 @@ CREATE FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }}( {% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} {% if is_columns.append('1') %}{% endif %} {{conn|qtIdent(c.attname)}} {% if is_sql %}{{ c.fulltype }}{% else %}{{c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}{% endif %}{% if c.coloptions %} -{% for o in c.coloptions %}{% if o.option and o.value %} +{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} {% endfor %}{% endif %} {% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %} @@ -36,7 +36,7 @@ CREATE FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }}( SERVER {{ conn|qtIdent(data.ftsrvname) }}{% if ftoptions %} {% for o in ftoptions %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} {% endfor %}{% endif %}; {% if data.owner or o_data.owner%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql index 24ea674bc..e78766d20 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql @@ -26,7 +26,7 @@ ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} ADD COLUMN {{conn|qtIdent(c.attname)}} {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %} {% if c.coloptions %} -{% for o in c.coloptions %}{% if o.option and o.value %} +{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} {% endfor %}{% endif %} {% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %} @@ -72,13 +72,13 @@ ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} {% endif %} {% endfor %} {% for o in c.coloptions_updated.added %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} {% if loop.first %}ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (ADD {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} {% endif %} {% endfor %} {% for o in c.coloptions_updated.changed %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} {% if loop.first %}ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (SET {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} {% endif %} @@ -142,21 +142,21 @@ ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} {% endif %} {% if data.ftoptions %} {% for o in data.ftoptions.deleted %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS ( DROP {{o.option}}); {% endif %} {% endfor %} {% for o in data.ftoptions.added %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}}); {% endif %} {% endfor %} {% for o in data.ftoptions.changed %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS (SET {{o.option}} {{o.value|qtLiteral}}); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/create.sql index b9b754a76..20af14492 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/create.sql @@ -12,7 +12,7 @@ CREATE FOREIGN TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ c SERVER {{ conn|qtIdent(data.ftsrvname) }}{% if data.ftoptions %} {% for o in data.ftoptions %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} {% endfor %}{% endif -%}; {% if data.owner %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/update.sql index a21034e5c..6539fb151 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/update.sql @@ -57,21 +57,21 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} {% endif -%} {% if data.ftoptions %} {% for o in data.ftoptions.deleted %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS (DROP {{o.option}}); {% endif %} {% endfor %} {% for o in data.ftoptions.added %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}}); {% endif %} {% endfor %} {% for o in data.ftoptions.changed %} -{% if o.option and o.value %} +{% if o.option is defined and o.value is defined %} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS (SET {{o.option}} {{o.value|qtLiteral}});