public inbox for [email protected]  
help / color / mirror / Atom feed
From: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch]: RM1669 - Cannot remove nor change length definition on column in "The Table Dialog"
Date: Thu, 15 Sep 2016 15:51:34 +0530
Message-ID: <CAM5-9D8mA4s8E6herkBji27xMqO22xRVXqXEqXkbC_LUNCgHFA@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi

Please find attached patch.

> Add proper check for the column length and precision in Jinja template.


​Please review.


Thanks,
Surinder Kumar​


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] RM1669.patch (4.2K, 3-RM1669.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql
index 454f964..80f736a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql
@@ -8,13 +8,12 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}

 {% endif %}
 {###  Alter column type and collation ###}
-{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen and data.attlen != o_data.attlen) or (data.attprecision and data.attprecision != o_data.attprecision) %}
+{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen and data.attlen != o_data.attlen) or (data.attprecision or data.attprecision != o_data.attprecision) %}
 ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
     ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {% if data.cltype %}{{conn|qtTypeIdent(data.cltype)}} {% else %}{{conn|qtTypeIdent(o_data.cltype)}} {% endif %}
-{% if data.attlen %}({{data.attlen}}{% elif not data.cltype %}({{o_data.attlen}}{% endif %}{% if data.attprecision%}, {{data.attprecision}}){% elif not data.cltype %}, {{o_data.attprecision}}){% elif data.attlen %}){% endif %}{% if data.hasSqrBracket %}
+{% if data.attlen and data.attlen != 'None' %}({{data.attlen}}{% if data.attlen != 'None' and data.attprecision %}, {{data.attprecision}}){% elif (data.cltype is defined and not data.cltype) %}, {{o_data.attprecision}}){% elif data.attlen %}){% endif %}{% endif %}{% if data.hasSqrBracket %}
 []{% endif %}{% if data.collspcname and data.collspcname != o_data.collspcname %}
  COLLATE {{data.collspcname}}{% endif %};
-
 {% endif %}
 {###  Alter column default value ###}
 {% if data.defval and data.defval != o_data.defval %}
@@ -145,4 +144,4 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
 {% endfor %}
 {% endif %}

-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
index 77ef8ea..0fe8fdf 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
@@ -8,10 +8,10 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}

 {% endif %}
 {###  Alter column type and collation ###}
-{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen and data.attlen != o_data.attlen) or (data.attprecision and data.attprecision != o_data.attprecision) %}
+{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen and data.attlen != o_data.attlen) or (data.attprecision or data.attprecision != o_data.attprecision) %}
 ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
     ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {% if data.cltype %}{{conn|qtTypeIdent(data.cltype)}} {% else %}{{conn|qtTypeIdent(o_data.cltype)}} {% endif %}
-{% if data.attlen %}({{data.attlen}}{% elif not data.cltype %}({{o_data.attlen}}{% endif %}{% if data.attprecision%}, {{data.attprecision}}){% elif not data.cltype %}, {{o_data.attprecision}}){% elif data.attlen %}){% endif %}{% if data.hasSqrBracket %}
+{% if data.attlen and data.attlen != 'None' %}({{data.attlen}}{% if data.attlen != 'None' and data.attprecision %}, {{data.attprecision}}){% elif (data.cltype is defined and not data.cltype) %}, {{o_data.attprecision}}){% elif data.attlen %}){% endif %}{% endif %}{% if data.hasSqrBracket %}
 []{% endif %}{% if data.collspcname and data.collspcname != o_data.collspcname %}
  COLLATE {{data.collspcname}}{% endif %};
 {% endif %}
@@ -142,4 +142,4 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
 {% endif %}
 {% endfor %}
 {% endif %}
-{% endif %}
\ No newline at end of file
+{% endif %}


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgAdmin4][Patch]: RM1669 - Cannot remove nor change length definition on column in "The Table Dialog"
  In-Reply-To: <CAM5-9D8mA4s8E6herkBji27xMqO22xRVXqXEqXkbC_LUNCgHFA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox