public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin3][Extension]: Wrong SQL generated
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin3][Extension]: Wrong SQL generated
@ 2016-01-18 11:03  Surinder Kumar <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Surinder Kumar @ 2016-01-18 11:03 UTC (permalink / raw)
  To: pgadmin-hackers

Hi all,


While implementing Extension module in pgAdmin4, I came to know that there
is an bug in pgadmin3.

Following are the steps to reproduce it:
1. Edit an existing extension.
2. In definition tab, set schema and version fields to empty.
3. In SQL tab, it generates an sql for the changes made which is wrong, it
shouldn't generate sql for the schema and version field if it is kept
empty, both fields should be validated.


Below is the wrong SQL generated:

*ALTER EXTENSION btree_gin*
*  SET SCHEMA ;*
*ALTER EXTENSION btree_gin*
*  UPDATE TO ;*


Let me know for any comments.

Thanks
Surinder Kumar


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin3][Extension]: Wrong SQL generated
@ 2016-01-24 13:53  Neel Patel <[email protected]>
  parent: Surinder Kumar <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Neel Patel @ 2016-01-24 13:53 UTC (permalink / raw)
  To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers

Hi,

Please find attached patch file for the issue mentioned below.

*Issue:- *
When user "Edit" any existing extension module property, and try to change
the schema and version field to blank then SQL should not be generated for
the blank field.

Above issue is fixed with attached patch file.

Do review it and let us know for any comments.

Thanks,
Neel Patel

On Mon, Jan 18, 2016 at 4:33 PM, Surinder Kumar <
[email protected]> wrote:

> Hi all,
>
>
> While implementing Extension module in pgAdmin4, I came to know that there
> is an bug in pgadmin3.
>
> Following are the steps to reproduce it:
> 1. Edit an existing extension.
> 2. In definition tab, set schema and version fields to empty.
> 3. In SQL tab, it generates an sql for the changes made which is wrong, it
> shouldn't generate sql for the schema and version field if it is kept
> empty, both fields should be validated.
>
>
> Below is the wrong SQL generated:
>
> *ALTER EXTENSION btree_gin*
> *  SET SCHEMA ;*
> *ALTER EXTENSION btree_gin*
> *  UPDATE TO ;*
>
>
> Let me know for any comments.
>
> 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] extension_fix.patch (897B, 3-extension_fix.patch)
  download | inline diff:
diff --git a/pgadmin/dlg/dlgExtension.cpp b/pgadmin/dlg/dlgExtension.cpp
index cfa62a3..7c2362e 100644
--- a/pgadmin/dlg/dlgExtension.cpp
+++ b/pgadmin/dlg/dlgExtension.cpp
@@ -180,10 +180,10 @@ wxString dlgExtension::GetSql()
 	if (extension)
 	{
 		// edit mode
-		if (cbObjectsSchema->GetValue() != extension->GetSchemaStr())
+		if (!cbObjectsSchema->GetValue().IsEmpty() && cbObjectsSchema->GetValue() != extension->GetSchemaStr())
 			sql += wxT("ALTER EXTENSION ") + qtIdent(extension->GetName())
 			       +  wxT("\n  SET SCHEMA ") + qtIdent(cbObjectsSchema->GetValue()) + wxT(";\n");
-		if (cbVersion->GetValue() != extension->GetVersion())
+		if (!cbVersion->GetValue().IsEmpty() && cbVersion->GetValue() != extension->GetVersion())
 			sql += wxT("ALTER EXTENSION ") + qtIdent(extension->GetName())
 			       +  wxT("\n  UPDATE TO ") + qtIdent(cbVersion->GetValue()) + wxT(";\n");
 	}


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2016-01-24 13:53 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18 11:03 [pgAdmin3][Extension]: Wrong SQL generated Surinder Kumar <[email protected]>
2016-01-24 13:53 ` Neel Patel <[email protected]>

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