Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 95d9cf46

Von Christian Ehringfeld vor fast 9 Jahren hinzugefügt

  • ID 95d9cf46f08c63b9c2cd6ec17e69a39301d3e8f1
  • Vorgänger f13a6e62
  • Nachfolger 77000f90

...

Unterschiede anzeigen:

src/entityhelper.cpp
if(!props.contains(attributeName) ||
superObject->getInheritanceStrategy() == InheritanceStrategy::PER_CLASS_TABLE) {
break;
} else if(!first){
} else if(!first) {
delete objectBefore;
objectBefore = nullptr;
} else {
......
auto i = props.constBegin();
while (i != props.constEnd()) {
if (!transientAttrs.contains(i.key()) && !relations.contains(i.key())) {
map.insert(i.key(), i.value().read(entity.data()));
if(i.value().isEnumType()) {
map.insert(i.key(), i.value().read(entity.data()).toInt());
} else {
map.insert(i.key(), i.value().read(entity.data()));
}
}
++i;
}
src/entitymanager.cpp
return this->executeQuery(this->schema->getQueryBuilder()->dropTable(className));
}
quint8 EntityManager::count(const QSharedPointer<Entity> &entity, bool ignoreID,
quint32 EntityManager::count(const QSharedPointer<Entity> &entity, bool ignoreID,
bool followInheritance) {
Query q = Query();
auto qb = this->schema->getQueryBuilder();
......
return this->count(q);
}
quint8 EntityManager::count(const QString &tableName) {
quint32 EntityManager::count(const QString &tableName) {
qint8 rc = -1;
QSqlQuery q = this->schema->getQueryBuilder()->count(tableName);
this->db->select(q);
......
return rc;
}
qint8 EntityManager::count(Query &query) {
quint32 EntityManager::count(Query &query) {
qint8 rc = 0;
query.appendSelect("COUNT(*)");
QSqlQuery q = this->queryInterpreter->build(query);
src/entitymanager.h
bool createRelationTables = true);
bool createTable(QString className, bool createRelationTables = true);
bool removeTable(QString className);
quint8 count(const QSharedPointer<Entity> &entity, bool ignoreID = true,
quint32 count(const QSharedPointer<Entity> &entity, bool ignoreID = true,
bool followInheritance = false);
quint8 count(const QString &tableName);
quint32 count(const QString &tableName);
QSharedPointer<Database> getDb() const;
void setDb(const QSharedPointer<Database> &value);
QSharedPointer<Schema> getSchema() const;
......
void refresh(QSharedPointer<Entity> &entity);
QList<QHash<QString, QVariant>> selectByQuery(Query &query);
QList<QHash<QString, QVariant>> selectBySql(const QString &sql);
qint8 count(Query &query);
quint32 count(Query &query);
/**
* @brief EntityManager::validate
* This validates an entity. Its uses the validationRules() method of the specified entity.
tests/em/tst_em.cpp
QVERIFY(article2);
entity = article2.objectCast<Entity>();
QVERIFY(this->e->remove(entity));
QCOMPARE(this->e->count("article"), (quint8)0);
QCOMPARE(this->e->count("article"), (quint32)0);
}
void EmTest::init() {
tests/em/tst_querybuilder.cpp
QCOMPARE(g->getLeader()->getFamilyName(), QString("Sey."));
}
void QuerybuilderTest::testFindByAttributesSuperClassAttribute() {
auto qb = e->getQueryBuilder();
Query q = Query();
q.appendWhere(q.equal(qb, "nickName", QString("Lotta")));
QList<QSharedPointer<Employee>> list = e->find<Employee>(q, true);
QCOMPARE(list.size(), 1);
QCOMPARE(list.at(0)->getPersNumber(), (unsigned long long)42);
}
void QuerybuilderTest::testQueryBuilderCount() {
QVariant var;
var.setValue(Person::Gender::FEMALE);
auto qb = e->getQueryBuilder();
Query q = Query();
q.appendWhere(q.equal(qb, "gender", var.toInt()));
q.appendFrom("person");
QCOMPARE(this->e->count(q), (quint32)4);
}
void QuerybuilderTest::testFindByAttributesManyToOneRelation() {
QHash<QString, QVariant> attributes;
tests/em/tst_querybuilder.h
void testFindByAttributesOneToManyResolve();
void testFindByAttributesOneToOneResolve();
void testFindByAttributesManyToOneResolve();
void testFindByAttributesSuperClassAttribute();
void testQueryBuilderCount();
void testQueryBuilder();
void testQueryBuilderEntityInheritance();
void testQueryBuilderEntityInheritanceWithoutJoin();

Auch abrufbar als: Unified diff