public inbox for [email protected]  
help / color / mirror / Atom feed
Unable to update Domain properly
3+ messages / 2 participants
[nested] [flat]

* Unable to update Domain properly
@ 2016-01-13 13:13 Khushboo Vashi <[email protected]>
  2016-01-13 17:27 ` Re: Unable to update Domain properly Neel Patel <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Khushboo Vashi @ 2016-01-13 13:13 UTC (permalink / raw)
  To: pgadmin-hackers

Hi,

While updating Domain from pgAdmin-III  , I observed an error.

When I update only Domain name it is working properly, but when I try to
update multiple fields, I get an error.

For example,  if I try to rename Domain *TestDomain* to *TestDomain1* and
also modifies one or more fields (except comment). I get below error.


ERROR:  type "pem.TestDomain" does not exist

*Generated SQL:*

ALTER DOMAIN pem."TestDomain"
  RENAME TO "TestDomain1";
ALTER DOMAIN pem."TestDomain"
  DROP NOT NULL;


Thanks,
Khushboo


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

* Re: Unable to update Domain properly
  2016-01-13 13:13 Unable to update Domain properly Khushboo Vashi <[email protected]>
@ 2016-01-13 17:27 ` Neel Patel <[email protected]>
  2016-01-14 06:41   ` Re: Unable to update Domain properly Neel Patel <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Neel Patel @ 2016-01-13 17:27 UTC (permalink / raw)
  To: Khushboo Vashi <[email protected]>; +Cc: pgadmin-hackers

Hi,

Please find the attached patch file for fix of above issue.

*Issue:- *
Below generated SQL was wrong.

ALTER DOMAIN pem."TestDomain"
  RENAME TO "TestDomain1";
ALTER DOMAIN pem."TestDomain"
  DROP NOT NULL;

In second query, domain name is wrong as domain name was updated by the
first query.

*Resolution:-*

Now when any properties got changed along with domain name then correct SQL
will be generated.
Correct query should be as below.

ALTER DOMAIN pem."TestDomain"
  RENAME TO "TestDomain1";
ALTER DOMAIN pem."TestDomain1"
  DROP NOT NULL;

Please review it and do let us know for any comment.

Thanks,
Neel Patel

On Wed, Jan 13, 2016 at 6:43 PM, Khushboo Vashi <
[email protected]> wrote:

> Hi,
>
> While updating Domain from pgAdmin-III  , I observed an error.
>
> When I update only Domain name it is working properly, but when I try to
> update multiple fields, I get an error.
>
> For example,  if I try to rename Domain *TestDomain* to *TestDomain1* and
> also modifies one or more fields (except comment). I get below error.
>
>
> ERROR:  type "pem.TestDomain" does not exist
>
> *Generated SQL:*
>
> ALTER DOMAIN pem."TestDomain"
>   RENAME TO "TestDomain1";
> ALTER DOMAIN pem."TestDomain"
>   DROP NOT NULL;
>
>
> Thanks,
> Khushboo
>


-- 
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] domain_fix.patch (1.5K, 3-domain_fix.patch)
  download | inline diff:
diff --git a/pgadmin/dlg/dlgDomain.cpp b/pgadmin/dlg/dlgDomain.cpp
index a3992f2..073850c 100644
--- a/pgadmin/dlg/dlgDomain.cpp
+++ b/pgadmin/dlg/dlgDomain.cpp
@@ -292,7 +292,7 @@ wxString dlgDomain::GetSql()
 		}
 		if (chkNotNull->GetValue() != domain->GetNotNull())
 		{
-			sql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier();
+			sql += wxT("ALTER DOMAIN ") + qtIdent(name);
 			if (chkNotNull->GetValue())
 				sql += wxT("\n  SET NOT NULL;\n");
 			else
@@ -300,7 +300,7 @@ wxString dlgDomain::GetSql()
 		}
 		if (txtDefault->GetValue() != domain->GetDefault())
 		{
-			sql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier();
+			sql += wxT("ALTER DOMAIN ") + qtIdent(name);
 			if (txtDefault->GetValue().IsEmpty())
 				sql += wxT("\n  DROP DEFAULT;\n");
 			else
@@ -318,7 +318,7 @@ wxString dlgDomain::GetSql()
 				tmpDef.RemoveAt(index);
 			else
 			{
-				tmpsql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier()
+				tmpsql += wxT("ALTER DOMAIN ") + qtIdent(name);
 				          +  wxT("\n  ADD");
 				if (!conname.IsEmpty())
 					tmpsql += wxT(" CONSTRAINT ");
@@ -335,9 +335,8 @@ wxString dlgDomain::GetSql()
 				definition = definition.Mid(1).BeforeFirst('"');
 			else
 				definition = definition.BeforeFirst(' ');
-			sql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier()
+			sql += wxT("ALTER DOMAIN ") + qtIdent(name)
 			       + wxT("\n  DROP CONSTRAINT ") + qtIdent(definition) + wxT(";\n");
-
 		}
 
 		// Add the ADD CONSTRAINTs...


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

* Re: Unable to update Domain properly
  2016-01-13 13:13 Unable to update Domain properly Khushboo Vashi <[email protected]>
  2016-01-13 17:27 ` Re: Unable to update Domain properly Neel Patel <[email protected]>
@ 2016-01-14 06:41   ` Neel Patel <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Neel Patel @ 2016-01-14 06:41 UTC (permalink / raw)
  To: Khushboo Vashi <[email protected]>; +Cc: pgadmin-hackers

Hi,

Please find updated patch file with the fix of below issue.

*Issue: -*

Earlier patch file will work only when in "public" schema.
If we change the schema name then generated name should contain both
"<schema_name>"."<domain_name>".
Attached patch file will include the schema name along with domain name.

Thanks Khushboo for point out the issue.

Thanks,
Neel Patel

On Wed, Jan 13, 2016 at 10:57 PM, Neel Patel <[email protected]>
wrote:

> Hi,
>
> Please find the attached patch file for fix of above issue.
>
> *Issue:- *
> Below generated SQL was wrong.
>
> ALTER DOMAIN pem."TestDomain"
>   RENAME TO "TestDomain1";
> ALTER DOMAIN pem."TestDomain"
>   DROP NOT NULL;
>
> In second query, domain name is wrong as domain name was updated by the
> first query.
>
> *Resolution:-*
>
> Now when any properties got changed along with domain name then correct
> SQL will be generated.
> Correct query should be as below.
>
> ALTER DOMAIN pem."TestDomain"
>   RENAME TO "TestDomain1";
> ALTER DOMAIN pem."TestDomain1"
>   DROP NOT NULL;
>
> Please review it and do let us know for any comment.
>
> Thanks,
> Neel Patel
>
> On Wed, Jan 13, 2016 at 6:43 PM, Khushboo Vashi <
> [email protected]> wrote:
>
>> Hi,
>>
>> While updating Domain from pgAdmin-III  , I observed an error.
>>
>> When I update only Domain name it is working properly, but when I try to
>> update multiple fields, I get an error.
>>
>> For example,  if I try to rename Domain *TestDomain* to *TestDomain1*
>> and also modifies one or more fields (except comment). I get below error.
>>
>>
>> ERROR:  type "pem.TestDomain" does not exist
>>
>> *Generated SQL:*
>>
>> ALTER DOMAIN pem."TestDomain"
>>   RENAME TO "TestDomain1";
>> ALTER DOMAIN pem."TestDomain"
>>   DROP NOT NULL;
>>
>>
>> Thanks,
>> Khushboo
>>
>
>


-- 
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] domain_fix_V2.patch (1.6K, 3-domain_fix_V2.patch)
  download | inline diff:
diff --git a/pgadmin/dlg/dlgDomain.cpp b/pgadmin/dlg/dlgDomain.cpp
index a3992f2..9c40b43 100644
--- a/pgadmin/dlg/dlgDomain.cpp
+++ b/pgadmin/dlg/dlgDomain.cpp
@@ -292,7 +292,7 @@ wxString dlgDomain::GetSql()
 		}
 		if (chkNotNull->GetValue() != domain->GetNotNull())
 		{
-			sql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier();
+			sql += wxT("ALTER DOMAIN ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(name);
 			if (chkNotNull->GetValue())
 				sql += wxT("\n  SET NOT NULL;\n");
 			else
@@ -300,7 +300,7 @@ wxString dlgDomain::GetSql()
 		}
 		if (txtDefault->GetValue() != domain->GetDefault())
 		{
-			sql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier();
+			sql += wxT("ALTER DOMAIN ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(name);
 			if (txtDefault->GetValue().IsEmpty())
 				sql += wxT("\n  DROP DEFAULT;\n");
 			else
@@ -318,7 +318,7 @@ wxString dlgDomain::GetSql()
 				tmpDef.RemoveAt(index);
 			else
 			{
-				tmpsql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier()
+				tmpsql += wxT("ALTER DOMAIN ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(name)
 				          +  wxT("\n  ADD");
 				if (!conname.IsEmpty())
 					tmpsql += wxT(" CONSTRAINT ");
@@ -335,9 +335,8 @@ wxString dlgDomain::GetSql()
 				definition = definition.Mid(1).BeforeFirst('"');
 			else
 				definition = definition.BeforeFirst(' ');
-			sql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier()
+			sql += wxT("ALTER DOMAIN ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(name)
 			       + wxT("\n  DROP CONSTRAINT ") + qtIdent(definition) + wxT(";\n");
-
 		}
 
 		// Add the ADD CONSTRAINTs...


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


end of thread, other threads:[~2016-01-14 06:41 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13 13:13 Unable to update Domain properly Khushboo Vashi <[email protected]>
2016-01-13 17:27 ` Neel Patel <[email protected]>
2016-01-14 06:41   ` 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