Herunterladen als
root/src/schema.h @ 6cfbc25e
c22391b2 | Christian Ehringfeld | /*
|
|
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
|
|||
*
|
|||
* This program is free software; you can redistribute it and/or modify it
|
|||
* under the terms of the GNU Lesser General Public License as published by
|
|||
* the Free Software Foundation.
|
|||
*
|
|||
* This program is distributed in the hope that it will be useful, but
|
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|||
* for more details.
|
|||
*
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
|||
aa44e7d1 | Christian Ehringfeld | #ifndef SCHEMA_H
|
|
#define SCHEMA_H
|
|||
9cf4747e | Christian Ehringfeld | #include <QStringList>
|
|
b0b8dac3 | Christian Ehringfeld | #include <QHash>
|
|
#include <QSharedPointer>
|
|||
14f9beed | Christian Ehringfeld | #include <QSqlField>
|
|
82442988 | Christian Ehringfeld | #include "tableschema.h"
|
|
b0bf458e | Christian Ehringfeld | #include "querybuilder.h"
|
|
4d58ef6a | Christian Ehringfeld | namespace CuteEntityManager {
|
|
14f9beed | Christian Ehringfeld | class Database;
|
|
4d58ef6a | Christian Ehringfeld | class Schema {
|
|
426974c6 | Christian Ehringfeld | public:
|
|
696666eb | Christian Ehringfeld | Schema(QSharedPointer<Database> database, QSharedPointer<QueryBuilder> builder);
|
|
b0b8dac3 | Christian Ehringfeld | virtual ~Schema();
|
|
24c5480c | Christian Ehringfeld | //http://doc.qt.io/qt-5/sql-types.html
|
|
b0b8dac3 | Christian Ehringfeld | const QString TYPE_PK = "pk";
|
|
const QString TYPE_BIGPK = "bigpk";
|
|||
const QString TYPE_STRING = "string";
|
|||
const QString TYPE_TEXT = "text";
|
|||
const QString TYPE_SMALLINT = "smallint";
|
|||
const QString TYPE_INTEGER = "integer";
|
|||
const QString TYPE_BIGINT = "bigint";
|
|||
const QString TYPE_FLOAT = "float";
|
|||
const QString TYPE_DOUBLE = "double";
|
|||
const QString TYPE_DECIMAL = "decimal";
|
|||
const QString TYPE_DATETIME = "datetime";
|
|||
const QString TYPE_TIMESTAMP = "timestamp";
|
|||
const QString TYPE_TIME = "time";
|
|||
const QString TYPE_DATE = "date";
|
|||
14f9beed | Christian Ehringfeld | const QString TYPE_CHAR = "char";
|
|
b0b8dac3 | Christian Ehringfeld | const QString TYPE_BINARY = "binary";
|
|
const QString TYPE_BOOLEAN = "boolean";
|
|||
const QString TYPE_MONEY = "money";
|
|||
a604a5a2 | Christian Ehringfeld | ||
24425325 | Christian Ehringfeld | virtual QSharedPointer<QHash<QString, QString> >getTypeMap() = 0;
|
|
a604a5a2 | Christian Ehringfeld | virtual QString quoteSimpleTableName(QString name);
|
|
426974c6 | Christian Ehringfeld | virtual QString quoteTableName(QString name);
|
|
virtual QString quoteColumnName(QString name);
|
|||
a604a5a2 | Christian Ehringfeld | virtual QString quoteSimpleColumnName(QString name);
|
|
e0e1ead8 | Christian Ehringfeld | virtual QHash<QString, QSharedPointer<TableSchema>> getTableSchemas(
|
|
QString schema = "",
|
|||
bool refresh = false);
|
|||
virtual QSharedPointer<TableSchema> getTableSchema(QString name,
|
|||
bool refresh = false);
|
|||
caea9141 | Christian Ehringfeld | virtual QStringList getTableNames(QString schema = "");
|
|
9cf4747e | Christian Ehringfeld | virtual QVariant getLastInsertID();
|
|
a604a5a2 | Christian Ehringfeld | virtual void refresh();
|
|
426974c6 | Christian Ehringfeld | virtual QString getRawTable(QString name);
|
|
14f9beed | Christian Ehringfeld | virtual bool containsTable(QString tblname);
|
|
b0b8dac3 | Christian Ehringfeld | ||
9cf4747e | Christian Ehringfeld | QHash<QString, QSharedPointer<TableSchema> > getTables() const;
|
|
void setTables(const QHash<QString, QSharedPointer<TableSchema> > &value);
|
|||
426974c6 | Christian Ehringfeld | ||
14f9beed | Christian Ehringfeld | QSharedPointer<Database> getDatabase() const;
|
|
void setDatabase(const QSharedPointer<Database> &value);
|
|||
b0bf458e | Christian Ehringfeld | QSharedPointer<QueryBuilder> getQueryBuilder() const;
|
|
24425325 | Christian Ehringfeld | QSharedPointer<QHash<QString, QString> > getAbstractTypeMap() const;
|
|
void setAbstractTypeMap(const QSharedPointer<QHash<QString, QString> > &value);
|
|||
ba800d6d | Christian Ehringfeld | protected:
|
|
9cf4747e | Christian Ehringfeld | virtual QStringList findTableNames(QString schema = "") = 0;
|
|
e0e1ead8 | Christian Ehringfeld | virtual QHash<QString, QStringList> findUniqueIndexes(const
|
|
QSharedPointer<TableSchema>
|
|||
&table) = 0;
|
|||
14f9beed | Christian Ehringfeld | virtual void findConstraints(const QSharedPointer<TableSchema> &ts) = 0;
|
|
virtual bool findColumns(const QSharedPointer<TableSchema> &ts) = 0;
|
|||
virtual QSharedPointer<TableSchema> loadTableSchema(QString name) = 0;
|
|||
696666eb | Christian Ehringfeld | virtual void initAbstractDatabaseTypes();
|
|
14f9beed | Christian Ehringfeld | QSharedPointer<Database> database;
|
|
QSharedPointer<QHash<QString, QString>> typeMap;
|
|||
24425325 | Christian Ehringfeld | QSharedPointer<QHash<QString, QString>> abstractTypeMap;
|
|
9cf4747e | Christian Ehringfeld | QHash<QString, QSharedPointer<TableSchema>> tables;
|
|
b0bf458e | Christian Ehringfeld | QSharedPointer<QueryBuilder> queryBuilder;
|
|
9cf4747e | Christian Ehringfeld | ||
2c152ba3 | Christian Ehringfeld | ||
4d58ef6a | Christian Ehringfeld | };
|
|
}
|
|||
aa44e7d1 | Christian Ehringfeld | #endif // SCHEMA_H
|