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;
|
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 PgClass::createTableSql() const
|
||||||
{
|
{
|
||||||
QString sql;
|
QString sql;
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ public:
|
||||||
// bool operator<(const PgClass &rhs) const { return oid < rhs.oid; }
|
// bool operator<(const PgClass &rhs) const { return oid < rhs.oid; }
|
||||||
|
|
||||||
QString createSql() const;
|
QString createSql() const;
|
||||||
|
QString typeName() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable QString createSqlCache;
|
mutable QString createSqlCache;
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,7 @@
|
||||||
#include "PgCollation.h"
|
#include "PgCollation.h"
|
||||||
|
|
||||||
|
QString PgCollation::typeName() const
|
||||||
|
{
|
||||||
|
return "COLLATION";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ public:
|
||||||
QString collcollate; // name
|
QString collcollate; // name
|
||||||
QString collctype; // name
|
QString collctype; // name
|
||||||
|
|
||||||
|
QString typeName() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PGCOLLATION_H
|
#endif // PGCOLLATION_H
|
||||||
|
|
|
||||||
|
|
@ -167,3 +167,8 @@ QString ForeignKeyMatchToString(ForeignKeyMatch fkm)
|
||||||
//{
|
//{
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
QString PgConstraint::typeName() const
|
||||||
|
{
|
||||||
|
return "CONSTRAINT";
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,8 @@ public:
|
||||||
QString definition;
|
QString definition;
|
||||||
|
|
||||||
using PgNamespaceObject::PgNamespaceObject;
|
using PgNamespaceObject::PgNamespaceObject;
|
||||||
|
|
||||||
|
QString typeName() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,6 @@
|
||||||
#include "PgDatabase.h"
|
#include "PgDatabase.h"
|
||||||
|
|
||||||
|
QString PgDatabase::typeName() const
|
||||||
|
{
|
||||||
|
return "DATABASE";
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@
|
||||||
class PgDatabase: public PgServerObject {
|
class PgDatabase: public PgServerObject {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Oid oid = InvalidOid;
|
|
||||||
// QString name;
|
|
||||||
Oid dba; // owner?
|
Oid dba; // owner?
|
||||||
int encoding;
|
int encoding;
|
||||||
QString collate;
|
QString collate;
|
||||||
|
|
@ -24,10 +22,7 @@ public:
|
||||||
|
|
||||||
bool isValid() const { return oid() != InvalidOid; }
|
bool isValid() const { return oid() != InvalidOid; }
|
||||||
|
|
||||||
// bool operator==(Oid _oid) const { return oid() == _oid; }
|
QString typeName() const override;
|
||||||
// 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(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PGDATABASE_H
|
#endif // PGDATABASE_H
|
||||||
|
|
|
||||||
|
|
@ -75,3 +75,8 @@ QString PgIndex::dropSql() const
|
||||||
% ";";
|
% ";";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PgIndex::typeName() const
|
||||||
|
{
|
||||||
|
return "INDEX";
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ public:
|
||||||
|
|
||||||
QString createSql() const;
|
QString createSql() const;
|
||||||
QString dropSql() const;
|
QString dropSql() const;
|
||||||
|
|
||||||
|
QString typeName() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PGINDEX_H
|
#endif // PGINDEX_H
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,8 @@ QString PgLanguage::dropSql() const
|
||||||
{
|
{
|
||||||
throw std::exception("PgLanguage::dropSql() not implemented");
|
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 isPlpgsql() const { return objectName() == "plpgsql"; }
|
||||||
bool isSql() const { return objectName() == "sql"; }
|
bool isSql() const { return objectName() == "sql"; }
|
||||||
|
|
||||||
|
QString typeName() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PGLANGUAGE_H
|
#endif // PGLANGUAGE_H
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,8 @@ bool PgNamespace::isSystemCatalog() const
|
||||||
return n.startsWith("pg_")
|
return n.startsWith("pg_")
|
||||||
|| n == "information_schema";
|
|| n == "information_schema";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PgNamespace::typeName() const
|
||||||
|
{
|
||||||
|
return "SCHEMA";
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,20 +9,13 @@
|
||||||
/// Object representing a namespace within a database
|
/// Object representing a namespace within a database
|
||||||
class PgNamespace: public PgDatabaseObject {
|
class PgNamespace: public PgDatabaseObject {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Oid oid = InvalidOid;
|
|
||||||
// QString name;
|
|
||||||
Oid owner = InvalidOid;
|
Oid owner = InvalidOid;
|
||||||
QString acl;
|
QString acl;
|
||||||
|
|
||||||
using PgDatabaseObject::PgDatabaseObject;
|
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;
|
bool isSystemCatalog() const;
|
||||||
|
QString typeName() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PGNAMESPACE_H
|
#endif // PGNAMESPACE_H
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ public:
|
||||||
const QString& objectName() const;
|
const QString& objectName() const;
|
||||||
/// Default implementation uses objectName and add quotes when needed.
|
/// Default implementation uses objectName and add quotes when needed.
|
||||||
virtual QString quotedObjectName() const;
|
virtual QString quotedObjectName() const;
|
||||||
|
virtual QString typeName() const = 0;
|
||||||
|
|
||||||
bool operator==(Oid _oid) const { return m_oid == _oid; }
|
bool operator==(Oid _oid) const { return m_oid == _oid; }
|
||||||
bool operator==(const QString &n) const { return m_name == n; }
|
bool operator==(const QString &n) const { return m_name == n; }
|
||||||
|
|
|
||||||
|
|
@ -370,3 +370,17 @@ QString PgProc::volatility() const
|
||||||
}
|
}
|
||||||
return "<unknown>";
|
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;
|
const QString& createSql() const;
|
||||||
QString argListWithNames(bool multiline = false) const;
|
QString argListWithNames(bool multiline = false) const;
|
||||||
QString argSigList(const bool forScript = false) const;
|
QString argSigList(const bool forScript = false) const;
|
||||||
|
|
||||||
QString volatility() const;
|
QString volatility() const;
|
||||||
|
|
||||||
bool isFunction() const { return kind == ProcKind::Function; }
|
bool isFunction() const { return kind == ProcKind::Function; }
|
||||||
|
|
@ -98,6 +97,7 @@ public:
|
||||||
bool isAggregate() const { return kind == ProcKind::Aggregate; }
|
bool isAggregate() const { return kind == ProcKind::Aggregate; }
|
||||||
bool isWindow() const { return kind == ProcKind::Window; }
|
bool isWindow() const { return kind == ProcKind::Window; }
|
||||||
|
|
||||||
|
QString typeName() const override;
|
||||||
// bool isTrigger() const
|
// bool isTrigger() const
|
||||||
// {
|
// {
|
||||||
// return typname == wxT("\"trigger\"") || typname == wxT("trigger") || typname == wxT("event_trigger") || typname == wxT("\"event_trigger\""))
|
// 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;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PgTrigger::typeName() const
|
||||||
|
{
|
||||||
|
return "TRIGGER";
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,8 @@ public:
|
||||||
//}
|
//}
|
||||||
|
|
||||||
QString arguments() const;
|
QString arguments() const;
|
||||||
|
|
||||||
|
QString typeName() const override;
|
||||||
private:
|
private:
|
||||||
mutable QString m_dropSql; // cache
|
mutable QString m_dropSql; // cache
|
||||||
mutable QString m_createSql; // cache
|
mutable QString m_createSql; // cache
|
||||||
|
|
|
||||||
|
|
@ -50,3 +50,8 @@ void operator<<(TypCategory &s, const Pgsql::Value &v)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PgType::typeName() const
|
||||||
|
{
|
||||||
|
return "TYPE";
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ public:
|
||||||
|
|
||||||
using PgNamespaceObject::PgNamespaceObject;
|
using PgNamespaceObject::PgNamespaceObject;
|
||||||
|
|
||||||
|
QString typeName() const override;
|
||||||
|
|
||||||
// bool operator==(Oid _oid) const { return oid == _oid; }
|
// bool operator==(Oid _oid) const { return oid == _oid; }
|
||||||
// bool operator==(const QString &n) const { return name == n; }
|
// bool operator==(const QString &n) const { return name == n; }
|
||||||
// bool operator<(Oid _oid) const { return oid < _oid; }
|
// bool operator<(Oid _oid) const { return oid < _oid; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue