Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jM3x0-0007BM-VT for pgadmin-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 06:12:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jM3wz-0001VA-Ry for pgadmin-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 06:12:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jM3wz-0001UT-D8 for pgadmin-hackers@lists.postgresql.org; Wed, 08 Apr 2020 06:12:37 +0000 Received: from mail-il1-x141.google.com ([2607:f8b0:4864:20::141]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jM3ww-0003zO-RO for pgadmin-hackers@postgresql.org; Wed, 08 Apr 2020 06:12:36 +0000 Received: by mail-il1-x141.google.com with SMTP id g15so5623661ilj.10 for ; Tue, 07 Apr 2020 23:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VSIQzGV9CuRHaE0yCpRSq5zUtaBrN8Ee5Z9EM5W6y3g=; b=gwjtrpgF3Rpu4twk22j4mvq6OJi9eKdLcDsADkZBZoCS9iU5XjtNQgpxwvLvav4uI2 j0dll6pfSuv7RrqSG2vFr8Lsqz6W6FbWCtuXu2/QHF1H8HHAqujnEuI2Cq9lSNkLAX6N YSkt+gpFBrJ2NVTP5ncz3DJsttq8Bxk/gj6DkVkj8fh6sZqjwPCPrVz93JX5rgUP1W2m Vc58+kSaSb2MkKF4mHOMC33N9aA7VEK6OqIyenXXw48T17XIciQt+cZI/pPCmOUn3VBU NbRlOSq+aXeb32B/eNtJNhICD8oB1Fk7r+pFonEK9jSwK6Ln/THu8fLPJ0CRgtGXk7wh +LKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VSIQzGV9CuRHaE0yCpRSq5zUtaBrN8Ee5Z9EM5W6y3g=; b=UUds/LcVCPq/rh0haand0ek63aCI1/JfpMVDisQ1w7UBQMBoPvlyt2vTHX4thIeidl jEd4x+P+gcM2xu/do2e/IlKeBxemlaIZb9WwmuVtlB4YvkA1GdiykzCL5TAa23Z/EIp9 30qTd0Nhuc89f2eXLjD2PUx3/xkUqrjRqYhrbhxCyB0XK1ptqLdmNgsv/kEEk+ndZATl iJGOlQcOzTi5MU4a/t4ba/k3TW7cb/R1ixCLW4pZQer9JO2KkrrLfkoglBWEP8/o0sTO ZpZCYdBpfjfZc/D62q5uuAx3iqHZS0E6x8Qv/gAR972L/d1eTn+oZzsW+h1hkyKgiFs7 m3PA== X-Gm-Message-State: AGi0PuZ3MUL4qytms49VYwNOXFzxvbh9KXllbVr/Yg9b3M2MkKHS+CrV zLQLyOt09LG41JYZAkaLUtw3Rnsu1Fqi0wfo3FI0YKStRJSUedhTTyySQqHuNexd5hE1GtV9SS8 mX8fQgXdENiS086ngKPkci/kRtMy8qxOTIAJueu9a6iknMUYGr7I9u3sy4ty7v3ykOKMowbRLfL YYRAhvoGQj1TxaPILb3OHJ7RdVzRwow2TGwH6Q80Ty1zaCQDWXQ5p7tl44 X-Google-Smtp-Source: APiQypLWeb3bAftcPeTeagNjh5bkiNNtgmTR/VAot9xIq0UaFM3Il3Fhi8OkjUV1VYhB+N4zmDD/EItQk9kFT23onp4= X-Received: by 2002:a92:8c45:: with SMTP id o66mr6527860ild.236.1586326353706; Tue, 07 Apr 2020 23:12:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Akshay Joshi Date: Wed, 8 Apr 2020 11:42:22 +0530 Message-ID: Subject: Re: [pgAdmin4][Patch]: RM 5053 - Getting an error while changing the columns in the existing view To: Khushboo Vashi Cc: pgadmin-hackers Content-Type: multipart/alternative; boundary="000000000000cfa46c05a2c16261" X-CLOUD-SEC-AV-Info: edb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000cfa46c05a2c16261 Content-Type: text/plain; charset="UTF-8" Thanks, patch applied. On Wed, Apr 8, 2020 at 10:58 AM Khushboo Vashi < khushboo.vashi@enterprisedb.com> wrote: > Hi Akshay, > > Please find the attached updated patch. > > Thanks, > Khushboo > > On Tue, Apr 7, 2020 at 11:43 AM Akshay Joshi < > akshay.joshi@enterprisedb.com> wrote: > >> Hi Khushboo >> >> The warning message is not showing up. Please fix and resend the patch. >> >> On Tue, Apr 7, 2020 at 10:00 AM Khushboo Vashi < >> khushboo.vashi@enterprisedb.com> wrote: >> >>> Hi Akshay, >>> >>> Please find the attached updated patch. >>> >>> On Tue, Mar 24, 2020 at 2:47 PM Akshay Joshi < >>> akshay.joshi@enterprisedb.com> wrote: >>> >>>> Hi Khushboo >>>> >>>> On Tue, Mar 24, 2020 at 1:47 PM Khushboo Vashi < >>>> khushboo.vashi@enterprisedb.com> wrote: >>>> >>>>> Hi Akshay, >>>>> >>>>> On Tue, Jan 14, 2020 at 11:47 AM Akshay Joshi < >>>>> akshay.joshi@enterprisedb.com> wrote: >>>>> >>>>>> Hi Khushboo >>>>>> >>>>>> Following are the review comments: >>>>>> >>>>>> - Fix the PEP8 issue. >>>>>> - Drop query should be part of the jinja template for >>>>>> consistency. Currently, it is added through the python file. >>>>>> >>>>>> The Delete query is already in the template file, I have just reused >>>>> the delete call and merged the SQL queries in the python file. >>>>> >>>>>> >>>>>> - Any changes in the view code should not warn the user "Changing >>>>>> the columns in a view requires dropping...." and we should not drop the >>>>>> view. For example, I have only change the WHERE clause or added 'ORDER BY'. >>>>>> >>>>>> I have tested but couldn't reproduce this issue. Can you please let >>>>> me know the proper use case? >>>>> >>>> >>>> Create a view with 'SELECT 1;' as code. Then change the code to >>>> 'SELECT 1234;' and click on the Save button. >>>> Warning popup is displayed "Changing the columns in a view....". >>>> Click on the 'Yes' button and check the OID of the view. You will get the >>>> same OID, it means view is not recreated. >>>> >>>> >>> I can reproduce this issue with the given SQL but the problem is as per >>> the PostgreSQL documentation, (Ref: >>> https://www.postgresql.org/docs/12/sql-createview.html) >>> >>> "CREATE OR REPLACE VIEW is similar, but if a view of the same name >>> already exists, it is replaced. The new query must generate the same >>> columns that were generated by the existing view query (that is, the same >>> column names in the same order and with the same data types), but it may >>> add additional columns to the end of the list. The calculations giving rise >>> to the output columns may be completely different." >>> >>> So, I put a check on the columns and if the column is changed, the >>> message will popup. >>> >>> In case of the example given by you, the column name is not changed as >>> if you don't give the column name it will be default and I think view would >>> have the column names properly. >>> >>> >>>> I have observed below error in the browser while changing the code: >>>> view.js:241 Uncaught TypeError: Cannot read property >>>> 'replace' of undefined >>>> at child.onChange (view.js:241) >>>> at HTMLDivElement.dispatch (jquery.js:5237) >>>> at HTMLDivElement.elemData.handle (jquery.js:5044) >>>> >>>> Fixed. >>> >>> Thanks, >>> Khushboo >>> >>>> >>>>> Thanks, >>>>> Khushboo >>>>> >>>>>> >>>>>> >>>>> >>>>>> On Tue, Jan 14, 2020 at 10:27 AM Khushboo Vashi < >>>>>> khushboo.vashi@enterprisedb.com> wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> Please find the attached patch for RM #5053 - Getting an error while >>>>>>> changing the columns in the existing view. >>>>>>> >>>>>>> PostgreSQL doesn't allow to change the view columns. So, while >>>>>>> performing this task the existing view should be dropped first and then >>>>>>> recreate it and also user will get a warning first. >>>>>>> >>>>>>> Thanks, >>>>>>> Khushboo >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> *Thanks & Regards* >>>>>> *Akshay Joshi* >>>>>> >>>>>> *Sr. Software Architect* >>>>>> *EnterpriseDB Software India Private Limited* >>>>>> *Mobile: +91 976-788-8246* >>>>>> >>>>> >>>> >>>> -- >>>> *Thanks & Regards* >>>> *Akshay Joshi* >>>> >>>> *Sr. Software Architect* >>>> *EnterpriseDB Software India Private Limited* >>>> *Mobile: +91 976-788-8246* >>>> >>> >> >> -- >> *Thanks & Regards* >> *Akshay Joshi* >> >> *Sr. Software Architect* >> *EnterpriseDB Software India Private Limited* >> *Mobile: +91 976-788-8246* >> > -- *Thanks & Regards* *Akshay Joshi* *Sr. Software Architect* *EnterpriseDB Software India Private Limited* *Mobile: +91 976-788-8246* --000000000000cfa46c05a2c16261 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks, patch applied.=C2=A0

On Wed, Apr 8, 2020 at 10:= 58 AM Khushboo Vashi <khushboo.vashi@enterprisedb.com> wrote:
Hi Akshay,

=
Please find the attached updated patch.

Thank= s,
Khushboo

On Tue, Apr 7, 2020 at 11:43 AM Akshay Joshi <= ;akshay.= joshi@enterprisedb.com> wrote:
Hi=C2=A0Khushboo

= The warning message is not showing=C2=A0up. Please fix and resend the patch= .

On Tue, Apr 7, 2020 at 10:00 AM Khushboo Vashi <khushboo.vashi@enterpri= sedb.com> wrote:
Hi Akshay,

Please fi= nd the attached updated patch.

On Tue, Mar 24, 2020 at 2:47 PM Akshay Joshi = <aksh= ay.joshi@enterprisedb.com> wrote:
Hi=C2=A0Khushboo=

= On Tue, Mar 24, 2020 at 1:47 PM Khushboo Vashi <khushboo.vashi@enterprisedb.co= m> wrote:
Hi Akshay,

On Tue, Jan 14, 2020 at 11:47 = AM Akshay Joshi <akshay.joshi@enterprisedb.com> wrote:
Hi=C2=A0Khushboo<= div>
Following are the review comments:
  • Fix= the PEP8 issue.
  • Drop query should be part of the jinja template fo= r consistency. Currently, it is added through the python file.
The Delete query is already in the template file= , I have just reused the delete call and merged the SQL queries in the pyth= on file.=C2=A0
  • Any changes in the view code should not warn the u= ser "Changing the columns in a view requires dropping...." and we= should not drop the view. For example, I have only change the WHERE clause= or added 'ORDER BY'.=C2=A0
= I have tested but=C2=A0 couldn't reproduce this issue.=C2=A0 Can you pl= ease let me know the proper use case?
=C2=A0 =C2=A0Create a view with 'SELECT 1;' as code. T= hen change the code to 'SELECT 1234;' and click on the Save button.= =C2=A0
=C2=A0 =C2=A0Warning popup is displayed "Changing the= columns in a view....". Click on the 'Yes' button and check t= he OID of the view. You will get the same OID, it means view is not recreat= ed.
=C2=A0 =C2=A0=C2=A0
I can = reproduce this issue with the given SQL but the problem is as per the Postg= reSQL documentation, (Ref:=C2=A0https://www.postgresql.org/docs/1= 2/sql-createview.html)

"CREATE OR REPLACE VIEW= =C2=A0is similar, but if a view of the same name already exists, it is repl= aced. The new query must generate the same columns that were generated by t= he existing view query (that is, the same column names in the same order an= d with the same data types), but it may add additional columns to the end o= f the list. The calculations giving rise to the output columns may be compl= etely different."

So, I put a check on= the columns and if the column is changed, the message will popup.

In case of the example given by you, the column name is no= t changed as if you don't give the column name it will be default and I= think view would have the column names properly.
=C2=A0
=C2=A0 =C2=A0 I have observed below error in the b= rowser while changing the code:=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 view.js:241 Uncaught TypeError: Cannot read property 're= place' of undefined
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = at child.onChange (view.js:241)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 at HTMLDivElement.dispatch (jquery.js:5237)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 at HTMLDivElement.elemData.handle (jquery.js:5044)
<= div class=3D"gmail_quote">
Fixed.=C2=A0

Thanks,
Khushboo

Thanks,
Khushboo=
=C2=A0

On Tue, Jan 14, 2020 at 10:27 AM K= hushboo Vashi <khushboo.vashi@enterprisedb.com> wrote:
Hi,

Please find the attached patch for RM #5053 -=C2=A0Getting an error= while changing the columns in the existing view.

= PostgreSQL doesn't allow to change the view columns. So, while performi= ng this task the existing view should be dropped first and then recreate it= and also user will get a warning first.

Thanks,
Khushboo


--
Thanks & Regards
Akshay Joshi
<= font color=3D"#3333FF">Sr. Software Architect=
<= font color=3D"#000000" face=3D"arial, sans-serif">EnterpriseDB Software = India Private Limited
Mobile: +91 976-788-8246=


--
Thanks & Regards
Akshay Joshi
<= font color=3D"#3333FF">Sr. Software Architect=
<= font color=3D"#000000" face=3D"arial, sans-serif">EnterpriseDB Software = India Private Limited
Mobile: +91 976-788-8246=


--
Thanks & Regards
Akshay Joshi
<= font color=3D"#3333FF">Sr. Software Architect=
<= font color=3D"#000000" face=3D"arial, sans-serif">EnterpriseDB Software = India Private Limited
Mobile: +91 976-788-8246=


--
Thanks & Regards
=
Akshay Joshi
Sr. Software Architect
EnterpriseDB Software India Private Limited
=
Mobile: += 91 976-788-8246
--000000000000cfa46c05a2c16261--