[pgAdmin4][Patch]: RM #1994 Insert / update are truncating if column is character

From: Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com>
To: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: [pgAdmin4][Patch]: RM #1994 Insert / update are truncating if column is character
Date: 2016-12-02 10:43:57
Message-ID: CANxoLDe7JaZ76CgtbuoKEqDCnUc+zL1FyNO0MqOEjTX-h9DDQg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Hi All

Please find the attached patch to fix the RM #1994 Insert / update are
truncating if column is character.

*Issue*: Create any column with datatype as character and provide some
length (10), now view the data in pgAdmin4 and try to insert/update that
column it gets truncated to one character. In insert/update query we have
type casted the value with data type like "col_val::character" but not
provided the length while type casting it, so it is truncated to one
character.

*Solution*: We can solve this in many ways(server side, client side), but
for server side it requires too much of code changes. So instead of doing
that I have fixed this at client side in "sqleditor.js" file from where we
send the modified/inserted data to the server. Following is the fix:

If datatype is "character" or "character varying" then check for it's
internal_size(length) and update the data type string as well as column
label to be shown on column headers.

After this fix if user inserts more character than the specified length it
will be truncated to that length and saved it into the database.

Please review it.

--
*Akshay Joshi*
*Principal Software Engineer *

*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*

Attachment Content-Type Size
RM_1994.patch application/octet-stream 1.5 KB

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Khushboo Vashi 2016-12-02 11:02:28 Re: [pgAdmin4][Patch]: RM #1801 : Properly handle databases with datallowconn == false
Previous Message Dave Page 2016-12-02 07:40:55 Re: Re: [pgAdmin4][Patch]: Fixes #1986 - Properly handle non-ascii characters while loading & saving file