Re: Re: [pgAdmin 4 - Bug #2274] Row Deletion Against Tables With PKs Not at Ordinal 0 Position Fail

From: Dave Page <dpage(at)pgadmin(dot)org>
To: Harshal Dhumal <harshal(dot)dhumal(at)enterprisedb(dot)com>
Cc: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>, waynewinchjr(at)earthlink(dot)net
Subject: Re: Re: [pgAdmin 4 - Bug #2274] Row Deletion Against Tables With PKs Not at Ordinal 0 Position Fail
Date: 2017-03-24 13:33:23
Message-ID: CA+OCxowXXOgiRjXDzhD5bMxWFkgKznXA2B-+RiKhisim57XSPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Thanks, patch applied.

On Fri, Mar 24, 2017 at 7:51 AM, Harshal Dhumal
<harshal(dot)dhumal(at)enterprisedb(dot)com> wrote:
> Hi,
>
> Here is patch for RM2274 (patch credits to Wayne Winch Jr)
>
> I tested this patch with below scenarios and all are working fine:
>
> 1. Table with 2 columns with 2nd col as primary key.
> 2. Table with 3 columns with 3rd and 2nd cols as primary key.
> 3. Table with 4 columns with 3rd and 2nd and 4th cols as primary key.
> 4. Table with 4 columns with 2nd and 4th cols as primary key.
> 5. Table with 4 columns with 4th col as primary key.
> 6. Table with 4 columns with 1st col as primary key.
>
>
>
> --
> Harshal Dhumal
> Software Engineer
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Mar 22, 2017 at 3:27 PM, <redmine(at)postgresql(dot)org> wrote:
>>
>> Issue #2274 has been updated by Dave Page.
>>
>> Priority changed from Normal to Urgent
>> Target version set to 1.4
>>
>> ________________________________
>>
>> Bug #2274: Row Deletion Against Tables With PKs Not at Ordinal 0 Position
>> Fail
>>
>> Author: Wayne Winch Jr
>> Status: New
>> Priority: Urgent
>> Assignee:
>> Category:
>> Target version: 1.4
>> Platform:
>> Area: User Interface
>>
>> If pgAdmin4 is used to delete one or more rows for tables having primary
>> keys that do not occupy the first column(s) of said table, the deletion will
>> fail with Python error --
>>
>> File
>> "/usr/lib/python3.5/site-packages/pgadmin4-web/pgadmin/tools/sqleditor/command.py",
>> line 499, in save
>> row[keys[int(k)]] = v
>> IndexError: list index out of range
>>
>> SIDE NOTE: A separate problem exists whereby pgAdmin4 does not adequately
>> indicate that an internal error (as listed above) has occurred as it merely
>> switches from the Data Output tab to the Messages tab whereby an old message
>> unrelated to the current or any exception is unhelpfully shown.
>>
>> The row deletion problem is caused by faulty logic within the command.py
>> file, TableCommand class, save() method in the 'deleted' operation branch
>> (Line 499) as indicated in the stack trace:
>>
>> row[keys[int(k)]] = v
>>
>> By changing this line to the following, the index mapping is performed
>> correctly (by bypassing keys list) for tables with non-ordinal, zero-based
>> PK column(s):
>>
>> row[changed_data['columns'][int(k)]['name']] = v
>>
>> This problem seems to have been introduced in pgAdmin4v1.3.
>>
>> ________________________________
>>
>> You have received this notification because you have either subscribed to
>> it, or are involved in it.
>> To change your notification preferences, please click here:
>> https://redmine.postgresql.org/my/account
>
>
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgadmin-hackers by date

  From Date Subject
Next Message Atira Odhner 2017-03-24 13:49:38 Re: [patch] Raise InternalServerError while retrieving table DDL
Previous Message Dave Page 2017-03-24 13:33:00 pgAdmin 4 commit: Fix deletion of rows where the primary key isn't at o