1
//////////////////////////////////////////////////////////////////////////
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: gqbTable.cpp 7812 2009-04-16 08:29:25Z dpage $
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
6
// This software is released under the BSD Licence
8
// gqbTable.cpp - Table object for GQB
10
//////////////////////////////////////////////////////////////////////////
19
#include "gqb/gqbObject.h"
20
#include "gqb/gqbTable.h"
21
#include "gqb/gqbColumn.h"
22
#include "gqb/gqbArrayCollection.h"
24
gqbTable::gqbTable(gqbObject *parent, wxString name, pgConn *connection, type_gqbObject type, OID oid)
25
: gqbObjectCollection(name, parent, connection, oid)
31
gqbIteratorBase* gqbTable::createColumnsIterator()
33
return createIterator();
37
void gqbTable::addColumn(gqbColumn *column)
39
this->addObject(column);
43
void gqbTable::createObjects(gqbBrowser *_tablesBrowser, pgConn *_conn, OID oidVal, wxTreeItemId parentNode)
45
createColumns(_conn, _tablesBrowser, parentNode, oidVal);
48
void gqbTable::createColumns(pgConn *conn, gqbBrowser *tablesBrowser, wxTreeItemId parentNode, OID oidVal)
51
wxString systemRestriction;
52
if (!settings->GetShowSystemObjects())
53
systemRestriction = wxT("\n AND attnum > 0");
56
wxT("SELECT attname FROM pg_attribute att\n")
57
wxT(" WHERE attrelid = ")
59
+ systemRestriction + wxT("\n")
60
wxT(" AND attisdropped IS FALSE\n")
61
wxT(" ORDER BY attnum");
63
pgSet *columns= conn->ExecuteSet(sql);
66
while (!columns->Eof())
70
//Disable, Column SHOULDN'T be added to tree only use for debug purposes tablesBrowser->AppendItem(parentNode, columns->GetVal(wxT("attname")) , -1, -1);
71
wxString tmpname = wxString(columns->GetVal(wxT("attname")));
72
gqbColumn *column = new gqbColumn(this, tmpname, conn);
73
this->addColumn(column);
85
//work as a synonym for function
86
int gqbTable::countCols()
88
return this->countObjects();
92
//work as a synonym for function & return correct type
93
gqbColumn* gqbTable::getColumnAtIndex(int index)
95
return (gqbColumn *)this->getObjectAtIndex(index);
99
int gqbTable::indexColumn(gqbColumn *col)
101
return this->indexObject(col);