Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Reverse engineer columns with multi-word names (like 'timestamp with …
Browse files Browse the repository at this point in the history
…timezone') correctly so that precision and array modifiers are included properly. Per Erwin.

git-svn-id: svn://svn.pgadmin.org/branches/REL-1_6_0_PATCHES@5759 a7884b65-44f6-0310-8a51-81a127f17b15
  • Loading branch information
dpage committed Dec 7, 2006
1 parent 503a5e6 commit 074dca1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Changes

Date Dev Ver Change details
---------- --- ----- --------------
2006-12-07 DP 1.6.2 Reverse engineer columns with multi-word names (like
'timestamp with timezone') correctly so that precision
and array modifiers are included properly. Per Erwin.
2006-12-07 DP 1.6.2 Add '...' to truncated column comments in table SQL, per
Erwin Brandstetter.
2006-12-05 DP 1.6.2 Properly size the backup dialog, per Patrick Headley.
Expand Down
2 changes: 1 addition & 1 deletion src/include/pgDatatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class pgDatatype
wxString Name() const { return name; };
wxString LengthString() const { return length; }
wxString Array() const { return array; }
wxString FullName() const { return name + length + array; }
wxString FullName() const;
wxString QuotedFullName() const { return qtTypeIdent(name) + length + array; }
wxString GetSchemaPrefix(pgDatabase *db) const;
wxString GetQuotedSchemaPrefix(pgDatabase *db) const;
Expand Down
2 changes: 1 addition & 1 deletion src/schema/pgColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ pgObject *pgColumnFactory::CreateObjects(pgCollection *coll, ctlTree *browser, c
long typmod=columns->GetLong(wxT("atttypmod"));
pgDatatype dt(columns->GetVal(wxT("typnspname")), columns->GetVal(wxT("typname")),
columns->GetBool(wxT("isdup")),
columns->GetBool(wxT("isarray"))? 1 : 0, typmod);
columns->GetLong(wxT("attndims")), typmod);


column->iSetTypmod(typmod);
Expand Down
18 changes: 17 additions & 1 deletion src/schema/pgDatatype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ pgDatatype::pgDatatype(const wxString &nsp, const wxString &typname, bool isDup,
length += wxT(",") + NumToStr(prec);
}
else if (name == wxT("time") || name == wxT("timetz")
|| name == wxT("time without time zone") || name == wxT("time with time zone")
|| name == wxT("timestamp") || name == wxT("timestamptz")
|| name == wxT("timestamp without time zone") || name == wxT("timestamp with time zone")
|| name == wxT("bit"))
{
prec=0;
Expand All @@ -83,7 +85,19 @@ pgDatatype::pgDatatype(const wxString &nsp, const wxString &typname, bool isDup,
len=prec=0;
}


wxString pgDatatype::FullName() const
{
if (name == wxT("time with time zone"))
return wxT("time") + length + wxT(" with time zone") + array;
else if (name == wxT("time without time zone"))
return wxT("time") + length + wxT(" without time zone") + array;
else if (name == wxT("timestamp with time zone"))
return wxT("timestamp") + length + wxT(" with time zone") + array;
else if (name == wxT("timestamp without time zone"))
return wxT("timestamp") + length + wxT(" without time zone") + array;
else
return name + length + array;
}

wxString pgDatatype::GetSchemaPrefix(pgDatabase *db) const
{
Expand Down Expand Up @@ -115,7 +129,9 @@ long pgDatatype::GetTypmod(const wxString &name, const wxString &len, const wxSt
return (((long)StrToLong(len) << 16) + StrToLong(prec)) +4;
}
else if (name == wxT("time") || name == wxT("timetz")
|| name == wxT("time without time zone") || name == wxT("time with time zone")
|| name == wxT("timestamp") || name == wxT("timestamptz")
|| name == wxT("timestamp without time zone") || name == wxT("timestamp with time zone")
|| name == wxT("interval") || name == wxT("bit"))
{
return StrToLong(len);
Expand Down

0 comments on commit 074dca1

Please sign in to comment.