Added typeName function to PgObject as it might be useful for building generic functions.
This commit is contained in:
parent
b210c570fc
commit
3f337b2cca
21 changed files with 83 additions and 15 deletions
|
|
@ -73,6 +73,21 @@ QString PgClass::createSql() const
|
|||
return createSqlCache;
|
||||
}
|
||||
|
||||
QString PgClass::typeName() const
|
||||
{
|
||||
switch (kind) {
|
||||
case RelKind::Table: return "TABLE";
|
||||
case RelKind::Index: return "INDEX";
|
||||
case RelKind::Sequence: return "SEQUENCE";
|
||||
case RelKind::View: return "VIEW";
|
||||
case RelKind::MaterializedView: return "MATERIALIZED VIEW";
|
||||
case RelKind::Composite: return "COMPOSITE";
|
||||
case RelKind::Toast: return "TOAST";
|
||||
case RelKind::ForeignTable: return "FOREIGN TABLE";
|
||||
}
|
||||
throw std::runtime_error("Unexpected value in PgClass::typeName()");
|
||||
}
|
||||
|
||||
QString PgClass::createTableSql() const
|
||||
{
|
||||
QString sql;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ public:
|
|||
// bool operator<(const PgClass &rhs) const { return oid < rhs.oid; }
|
||||
|
||||
QString createSql() const;
|
||||
QString typeName() const override;
|
||||
|
||||
private:
|
||||
mutable QString createSqlCache;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,7 @@
|
|||
#include "PgCollation.h"
|
||||
|
||||
QString PgCollation::typeName() const
|
||||
{
|
||||
return "COLLATION";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public:
|
|||
QString collcollate; // name
|
||||
QString collctype; // name
|
||||
|
||||
QString typeName() const override;
|
||||
};
|
||||
|
||||
#endif // PGCOLLATION_H
|
||||
|
|
|
|||
|
|
@ -167,3 +167,8 @@ QString ForeignKeyMatchToString(ForeignKeyMatch fkm)
|
|||
//{
|
||||
|
||||
//}
|
||||
|
||||
QString PgConstraint::typeName() const
|
||||
{
|
||||
return "CONSTRAINT";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ public:
|
|||
QString definition;
|
||||
|
||||
using PgNamespaceObject::PgNamespaceObject;
|
||||
|
||||
QString typeName() const override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,6 @@
|
|||
#include "PgDatabase.h"
|
||||
|
||||
QString PgDatabase::typeName() const
|
||||
{
|
||||
return "DATABASE";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
class PgDatabase: public PgServerObject {
|
||||
public:
|
||||
|
||||
// Oid oid = InvalidOid;
|
||||
// QString name;
|
||||
Oid dba; // owner?
|
||||
int encoding;
|
||||
QString collate;
|
||||
|
|
@ -24,10 +22,7 @@ public:
|
|||
|
||||
bool isValid() const { return oid() != InvalidOid; }
|
||||
|
||||
// bool operator==(Oid _oid) const { return oid() == _oid; }
|
||||
// bool operator==(const QString &n) const { return objectName() == n; }
|
||||
// bool operator<(Oid _oid) const { return oid() < _oid; }
|
||||
// bool operator<(const PgDatabase &rhs) const { return oid() < rhs.oid(); }
|
||||
QString typeName() const override;
|
||||
};
|
||||
|
||||
#endif // PGDATABASE_H
|
||||
|
|
|
|||
|
|
@ -75,3 +75,8 @@ QString PgIndex::dropSql() const
|
|||
% ";";
|
||||
return result;
|
||||
}
|
||||
|
||||
QString PgIndex::typeName() const
|
||||
{
|
||||
return "INDEX";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ public:
|
|||
|
||||
QString createSql() const;
|
||||
QString dropSql() const;
|
||||
|
||||
QString typeName() const override;
|
||||
};
|
||||
|
||||
#endif // PGINDEX_H
|
||||
|
|
|
|||
|
|
@ -9,3 +9,8 @@ QString PgLanguage::dropSql() const
|
|||
{
|
||||
throw std::exception("PgLanguage::dropSql() not implemented");
|
||||
}
|
||||
|
||||
QString PgLanguage::typeName() const
|
||||
{
|
||||
return "LANGUAGE";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public:
|
|||
bool isPlpgsql() const { return objectName() == "plpgsql"; }
|
||||
bool isSql() const { return objectName() == "sql"; }
|
||||
|
||||
QString typeName() const override;
|
||||
};
|
||||
|
||||
#endif // PGLANGUAGE_H
|
||||
|
|
|
|||
|
|
@ -6,3 +6,8 @@ bool PgNamespace::isSystemCatalog() const
|
|||
return n.startsWith("pg_")
|
||||
|| n == "information_schema";
|
||||
}
|
||||
|
||||
QString PgNamespace::typeName() const
|
||||
{
|
||||
return "SCHEMA";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,20 +9,13 @@
|
|||
/// Object representing a namespace within a database
|
||||
class PgNamespace: public PgDatabaseObject {
|
||||
public:
|
||||
|
||||
// Oid oid = InvalidOid;
|
||||
// QString name;
|
||||
Oid owner = InvalidOid;
|
||||
QString acl;
|
||||
|
||||
using PgDatabaseObject::PgDatabaseObject;
|
||||
|
||||
// bool operator==(Oid _oid) const { return oid == _oid; }
|
||||
// bool operator==(const QString &n) const { return objectName() == n; }
|
||||
// bool operator<(Oid _oid) const { return oid < _oid; }
|
||||
// bool operator<(const PgNamespace &rhs) const { return oid < rhs.oid; }
|
||||
|
||||
bool isSystemCatalog() const;
|
||||
QString typeName() const override;
|
||||
};
|
||||
|
||||
#endif // PGNAMESPACE_H
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public:
|
|||
const QString& objectName() const;
|
||||
/// Default implementation uses objectName and add quotes when needed.
|
||||
virtual QString quotedObjectName() const;
|
||||
virtual QString typeName() const = 0;
|
||||
|
||||
bool operator==(Oid _oid) const { return m_oid == _oid; }
|
||||
bool operator==(const QString &n) const { return m_name == n; }
|
||||
|
|
|
|||
|
|
@ -370,3 +370,17 @@ QString PgProc::volatility() const
|
|||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
QString PgProc::typeName() const
|
||||
{
|
||||
switch (kind) {
|
||||
case ProcKind::Function:
|
||||
case ProcKind::Window:
|
||||
return "FUNCTION";
|
||||
case ProcKind::Procedure:
|
||||
return "PROCEDURE";
|
||||
case ProcKind::Aggregate:
|
||||
return "AGGREGATE";
|
||||
}
|
||||
throw std::runtime_error("Unexpected kind in PgProc::typeName()");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ public:
|
|||
const QString& createSql() const;
|
||||
QString argListWithNames(bool multiline = false) const;
|
||||
QString argSigList(const bool forScript = false) const;
|
||||
|
||||
QString volatility() const;
|
||||
|
||||
bool isFunction() const { return kind == ProcKind::Function; }
|
||||
|
|
@ -98,6 +97,7 @@ public:
|
|||
bool isAggregate() const { return kind == ProcKind::Aggregate; }
|
||||
bool isWindow() const { return kind == ProcKind::Window; }
|
||||
|
||||
QString typeName() const override;
|
||||
// bool isTrigger() const
|
||||
// {
|
||||
// return typname == wxT("\"trigger\"") || typname == wxT("trigger") || typname == wxT("event_trigger") || typname == wxT("\"event_trigger\""))
|
||||
|
|
|
|||
|
|
@ -154,3 +154,8 @@ QString PgTrigger::arguments() const
|
|||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
QString PgTrigger::typeName() const
|
||||
{
|
||||
return "TRIGGER";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ public:
|
|||
//}
|
||||
|
||||
QString arguments() const;
|
||||
|
||||
QString typeName() const override;
|
||||
private:
|
||||
mutable QString m_dropSql; // cache
|
||||
mutable QString m_createSql; // cache
|
||||
|
|
|
|||
|
|
@ -50,3 +50,8 @@ void operator<<(TypCategory &s, const Pgsql::Value &v)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString PgType::typeName() const
|
||||
{
|
||||
return "TYPE";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ public:
|
|||
|
||||
using PgNamespaceObject::PgNamespaceObject;
|
||||
|
||||
QString typeName() const override;
|
||||
|
||||
// bool operator==(Oid _oid) const { return oid == _oid; }
|
||||
// bool operator==(const QString &n) const { return name == n; }
|
||||
// bool operator<(Oid _oid) const { return oid < _oid; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue