pgLab/pglablib/SqlFormattingUtils.h
eelke 73c4cf4790 Rework of catalog objects. Several of them are now inheriting from common
base classes that implement common functionality.
2018-11-25 19:45:06 +01:00

33 lines
1.6 KiB
C++

#ifndef SQLFORMATTINGUTILS_H
#define SQLFORMATTINGUTILS_H
#include <QString>
class PgClass;
class PgConstraint;
class PgDatabaseCatalog;
class PgIndex;
QString escapeIdent(const QString &input);
QString escapeLiteral(const QString &input);
bool identNeedsQuotes(QString ident);
QString quoteIdent(QString ident);
/// Puts a string in dollar quote for passing in a query
/// the standard quotes are $BODY$ if the tag already exists in the string it will start numbering
QString dollarQuoteString(const QString &value);
//QString genFQTableName(const PgDatabaseCatalog &catalog, const PgClass &cls);
QString getDropConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
QString getConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
QString getIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &index);
QString getDropIndexDefinition(const PgDatabaseCatalog &catalog, const PgIndex &index);
/// Returns the foreignKey specific part of the constraint definition
QString getForeignKeyConstraintDefinition(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
/// Returns the REFERENCES construct as used directly after a column in the create table statement
QString getForeignKeyConstraintReferences(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
/// Same as above but shortened as much as possible by leaving out defaults
QString getForeignKeyConstraintReferencesShort(const PgDatabaseCatalog &catalog, const PgConstraint &constraint);
#endif // SQLFORMATTINGUTILS_H