Revision 97f9a843
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
src/entity.h | ||
---|---|---|
#include <QMetaProperty>
|
||
#include "relation.h"
|
||
#include <QStringList>
|
||
#include <QSharedPointer>
|
||
namespace CuteEntityManager {
|
||
|
||
/**
|
||
... | ... | |
qint64 getId() const;
|
||
void setId(const qint64 &value);
|
||
|
||
protected:
|
||
protected:
|
||
qint64 id;
|
||
};
|
||
}
|
src/querybuilder.cpp | ||
---|---|---|
return map;
|
||
}
|
||
|
||
QList<QHash<QString, QString>> QueryBuilder::generateRelationTables(const QSharedPointer<Entity> &entity) {
|
||
QList<QHash<QString, QString>> QueryBuilder::generateRelationTables(const QSharedPointer<Entity> &entity) const {
|
||
QList<QHash<QString, QString>> relations = QList<QHash<QString, QString>>();
|
||
QHash<QString, Relation> m = entity.data()->getRelations();
|
||
QHash<QString, QSharedPointer<Entity>> os = entity.data()->getRelationObjects();
|
||
for(auto i = m.begin(); i != m.end(); ++i) {
|
||
Relation r = i.value();
|
||
if(r.getType() == HAS_MANY) {
|
||
QHash<QString, QString> h = QHash<QString, QString>();
|
||
h.insert("id",this->schema.data()->TYPE_BIGPK);
|
||
//h.insert(entity.data()->metaObject()->className()+ "_id", this->schema.data()->)
|
||
|
||
h.insert(QString(entity.data()->metaObject()->className())+ QString("_id"), this->schema.data()->TYPE_BIGINT);
|
||
if(os.contains(i.key())) {
|
||
h.insert(QString(os.value(i.key()).data()->metaObject()->className())+ QString("_id"),this->schema.data()->TYPE_BIGINT);
|
||
relations.append(h);
|
||
}
|
||
}
|
||
}
|
||
|
||
return relations;
|
||
}
|
||
|
||
|
src/querybuilder.h | ||
---|---|---|
|
||
QSharedPointer<Database> getDatabase() const;
|
||
void setDatabase(const QSharedPointer<Database> &value);
|
||
|
||
QList<QHash<QString, QString>> generateRelationTables(const QSharedPointer<Entity> &entity) const;
|
||
QHash<QString, QString> generateTableDefinition(const QSharedPointer<Entity> &entity) const;
|
||
|
||
QString transformTypeToAbstractDbType(QString typeName) const;
|
Auch abrufbar als: Unified diff
compiles