Rework of catalog objects. Several of them are now inheriting from common
base classes that implement common functionality.
This commit is contained in:
parent
840af1e0a9
commit
73c4cf4790
45 changed files with 340 additions and 265 deletions
|
|
@ -244,26 +244,26 @@ QString dollarQuoteString(const QString &value)
|
|||
|
||||
|
||||
|
||||
QString genSchemaPrefix(const PgNamespace &ns)
|
||||
{
|
||||
QString str;
|
||||
if (!ns.name.isEmpty()) {
|
||||
str = quoteIdent(ns.name) % QString::fromUtf16(u".");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
//QString genSchemaPrefix(const PgNamespace &ns)
|
||||
//{
|
||||
// QString str;
|
||||
// if (!ns.name.isEmpty()) {
|
||||
// str = quoteIdent(ns.name) % QString::fromUtf16(u".");
|
||||
// }
|
||||
// return str;
|
||||
//}
|
||||
|
||||
|
||||
QString genFQTableName(const PgDatabaseCatalog &catalog, const PgClass &cls)
|
||||
{
|
||||
auto ns = catalog.namespaces()->getByKey(cls.relnamespace);
|
||||
|
||||
return genSchemaPrefix(*ns) % quoteIdent(cls.name);
|
||||
}
|
||||
//QString genFQTableName(const PgDatabaseCatalog &catalog, const PgClass &cls)
|
||||
//{
|
||||
// auto ns = catalog.namespaces()->getByKey(cls.relnamespace);
|
||||
////cls.fullyQualifiedQuotedObjectName()
|
||||
// return ns->quotedObjectName() % "." % cls.quotedObjectName();
|
||||
//}
|
||||
|
||||
QString genAlterTable(const PgDatabaseCatalog &catalog, const PgClass &cls)
|
||||
{
|
||||
return "ALTER TABLE " % genFQTableName(catalog, cls);
|
||||
return "ALTER TABLE " % cls.fullyQualifiedQuotedObjectName(); // genFQTableName(catalog, cls);
|
||||
}
|
||||
|
||||
QString getDropConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint)
|
||||
|
|
@ -312,7 +312,7 @@ QString getForeignKeyConstraintDefinition(const PgDatabaseCatalog &catalog, cons
|
|||
|
||||
return "\n FOREIGN KEY ("
|
||||
% getColumnNameList(catalog, constraint.relid, constraint.key) % ")\n REFERENCES "
|
||||
% genFQTableName(catalog, *fcls) % " ("
|
||||
% fcls->fullyQualifiedQuotedObjectName() % " ("
|
||||
% getColumnNameList(catalog, constraint.frelid, constraint.fkey) % ")\n MATCH "
|
||||
% ForeignKeyMatchToString(constraint.fmatchtype)
|
||||
% " ON UPDATE " % ForeignKeyActionToString(constraint.fupdtype)
|
||||
|
|
@ -332,7 +332,7 @@ QString getForeignKeyConstraintReferences(const PgDatabaseCatalog &catalog, cons
|
|||
}
|
||||
|
||||
return "REFERENCES "
|
||||
% genFQTableName(catalog, *fcls) % " ("
|
||||
% fcls->fullyQualifiedQuotedObjectName() % " ("
|
||||
% getColumnNameList(catalog, constraint.frelid, constraint.fkey) % ") MATCH "
|
||||
% ForeignKeyMatchToString(constraint.fmatchtype)
|
||||
% " ON UPDATE " % ForeignKeyActionToString(constraint.fupdtype)
|
||||
|
|
@ -356,7 +356,7 @@ QString getForeignKeyConstraintReferencesShort(const PgDatabaseCatalog &catalog,
|
|||
QString on_delete = constraint.fdeltype == ForeignKeyAction::NoAction ? QString() : " ON DELETE " % ForeignKeyActionToString(constraint.fdeltype);
|
||||
QString match_type = constraint.fmatchtype == ForeignKeyMatch::Simple ? QString() : " MATCH " % ForeignKeyMatchToString(constraint.fmatchtype);
|
||||
|
||||
return genFQTableName(catalog, *fcls) % " ("
|
||||
return fcls->fullyQualifiedQuotedObjectName() % " ("
|
||||
% getColumnNameList(catalog, constraint.frelid, constraint.fkey) % ")"
|
||||
% match_type
|
||||
% on_update
|
||||
|
|
@ -406,7 +406,7 @@ QString getConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstr
|
|||
return result;
|
||||
}
|
||||
|
||||
QString getIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &index)
|
||||
QString getIndexDefinition(const PgDatabaseCatalog &, const PgIndex &index)
|
||||
{
|
||||
// const PgClass *table_class = catalog.classes()->getByKey(index.relid);
|
||||
// const PgClass *index_class = catalog.classes()->getByKey(index.indexrelid);
|
||||
|
|
@ -464,40 +464,8 @@ QString getDropIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &
|
|||
|
||||
QString result;
|
||||
result = "DROP INDEX "
|
||||
% quoteIdent(getIndexDisplayString(catalog, index.indexrelid))
|
||||
% index.fullyQualifiedQuotedObjectName() // quoteIdent(getIndexDisplayString(catalog, index.indexrelid))
|
||||
% ";";
|
||||
// % quoteIdent(index_class.name)
|
||||
// % "\n ON " % genFQTableName(catalog, table_class);
|
||||
//// % "\n USING " % index_class.am lookup in pg_am table
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
wxString sql;
|
||||
|
||||
sql = wxT("(") + GetQuotedFkColumns()
|
||||
+ wxT(")\n REFERENCES ") + GetQuotedSchemaPrefix(GetRefSchema()) + qtIdent(GetReferences())
|
||||
+ wxT(" (") + GetQuotedRefColumns()
|
||||
+ wxT(")");
|
||||
|
||||
if (GetDatabase()->BackendMinimumVersion(7, 4) || GetMatch() == wxT("FULL"))
|
||||
sql += wxT(" MATCH ") + GetMatch();
|
||||
|
||||
sql += wxT("\n ON UPDATE ") + GetOnUpdate()
|
||||
+ wxT(" ON DELETE ") + GetOnDelete();
|
||||
if (GetDeferrable())
|
||||
{
|
||||
sql += wxT(" DEFERRABLE INITIALLY ");
|
||||
if (GetDeferred())
|
||||
sql += wxT("DEFERRED");
|
||||
else
|
||||
sql += wxT("IMMEDIATE");
|
||||
}
|
||||
|
||||
if (GetDatabase()->BackendMinimumVersion(9, 1) && !GetValid())
|
||||
sql += wxT("\n NOT VALID");
|
||||
|
||||
return sql;
|
||||
*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue