Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a42de475

Von Christian Ehringfeld vor etwa 8 Jahren hinzugefügt

  • ID a42de475baab93158e436299dc0f3e69206ddbb6
  • Vorgänger 977d8d5f
  • Nachfolger 1ac14ffb

refs #621

Unterschiede anzeigen:

src/entitymanager.h
return QList<QSharedPointer<T>>();
}
template<class T> quint32 countEntities(Query &q, const bool joinBaseClasses = true) {
auto instance = QSharedPointer<Entity>(EntityInstanceFactory::createInstance<T *>());
quint32 count = 0;
if (instance) {
if (q.getFrom().isEmpty()) {
q.setFrom(QStringList(instance->getTablename()));
}
if (joinBaseClasses) {
q.appendJoins(this->schema->getQueryBuilder()->joinBaseClasses(instance));
}
q.appendSelect("COUNT(*)");
QSqlQuery query = this->queryInterpreter->build(q);
this->db->select(query);
if (query.next()) {
count = query.value(0).toInt();
}
}
return count;
}
template<class T>
bool remove(QSharedPointer<T> &entity) {
static_assert(std::is_base_of<Entity, T>::value, "T must inherit from Entity");
tests/em/tst_em.cpp
}
}
void EmTest::testCountEntities() {
Query q = Query();
auto count = this->e->countEntities<DatabaseMigration>(q, true);
QCOMPARE(count, (unsigned int)1);
}
void EmTest::testTableCreation() {
auto tables = this->e->getSchema()->getTables();
bool containsArticle = tables.contains("article");
tests/em/tst_em.h
void testInheritedRelations();
void testNonCachedInheritedRelations();
void testDatabaseMigrationTable();
void testCountEntities();
void testTableCreation();
private:

Auch abrufbar als: Unified diff