diff --git a/pgadmin/frm/frmEditGrid.cpp b/pgadmin/frm/frmEditGrid.cpp index 24d962d..55f88cc 100644 --- a/pgadmin/frm/frmEditGrid.cpp +++ b/pgadmin/frm/frmEditGrid.cpp @@ -2435,7 +2435,18 @@ sqlTable::sqlTable(pgConn *conn, pgQueryThread *_thread, const wxString &tabName columns[i].numeric = false; columns[i].attr->SetReadOnly(false); columns[i].needResize = true; - editor = new sqlGridTextEditor(); + + wxArrayString choices = GetChoicesIfIsEnum(connection, i); + + if (choices.GetCount() > 0) + { + editor = new wxGridCellChoiceEditor(choices); + } + else + { + editor = new sqlGridTextEditor(); + } + break; } if (editor) @@ -2509,6 +2520,34 @@ sqlTable::~sqlTable() } +wxArrayString sqlTable::GetChoicesIfIsEnum(pgConn *connection, int col) +{ + + wxArrayString choices; + + if (columns[col].type > 25000) + { + pgSet *enumSet = connection->ExecuteSet( + wxT("SELECT enumlabel") + wxT(" FROM pg_enum\n") + wxT(" WHERE enumtypid =") + NumToStr(columns[col].type) + wxT("") + wxT(" ORDER BY enumsortorder")); + + if (enumSet) + { + for (int l = 0; l < enumSet->NumRows(); l++) + { + choices.Add(enumSet->GetVal(wxT("enumlabel"))); + enumSet->MoveNext(); + } + delete enumSet; + } + } + + return choices; +} + + int sqlTable::GetNumberCols() { return nCols; diff --git a/pgadmin/include/frm/frmEditGrid.h b/pgadmin/include/frm/frmEditGrid.h index 3205136..b894dc3 100644 --- a/pgadmin/include/frm/frmEditGrid.h +++ b/pgadmin/include/frm/frmEditGrid.h @@ -163,6 +163,7 @@ public: bool StoreLine(); void UndoLine(int row); + wxArrayString GetChoicesIfIsEnum(pgConn *connection, int col); int GetNumberRows(); int GetNumberStoredRows(); int GetNumberCols();