Revision d2c33642
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
samples/example/main.cpp | ||
---|---|---|
q.setLimit(10);
|
||
QList<QSharedPointer<Pupil>> list = e->find<Pupil>(q, true);
|
||
for (int i = 0; i < list.size(); ++i) {
|
||
// qWarning() << "-----------------------------";
|
||
// qWarning() << "Merge Pupil";
|
||
// qWarning() << "-----------------------------";
|
||
// list.at(i)->setBirthday(QDate(2222,12,22));
|
||
// QSharedPointer<Entity> pupilE = list.at(i).objectCast<Entity>();
|
||
// e->merge(pupilE,true);
|
||
qWarning() << "-----------------------------";
|
||
qWarning() << "Merge Pupil";
|
||
qWarning() << "-----------------------------";
|
||
list.at(i)->setBirthday(QDate(2222,12,22));
|
||
QSharedPointer<Entity> pupilE = list.at(i).objectCast<Entity>();
|
||
e->merge(pupilE,true);
|
||
qWarning() << list.at(i)->toString();
|
||
}
|
||
qWarning() << "-----------------------------";
|
src/entitymanager.cpp | ||
---|---|---|
|
||
bool EntityManager::hasChanged(QSharedPointer<Entity> &entity) {
|
||
bool changed = true;
|
||
if (entity->getId() >= -1) {
|
||
if (entity->getId() > -1) {
|
||
changed = false;
|
||
auto listmap = this->findByPk(entity->getId(), entity);
|
||
auto relations = entity->getRelations();
|
||
... | ... | |
}
|
||
}
|
||
}
|
||
|
||
}
|
||
return changed;
|
||
}
|
||
... | ... | |
QSharedPointer<Entity> ptr;
|
||
for (int var = 0; var < list.size(); ++var) {
|
||
ptr = list.at(var);
|
||
if (this->shouldBeSaved(ptr, r) && this->save(ptr)) {
|
||
if (this->shouldBeSaved(ptr, r) && this->hasChanged(ptr) && this->save(ptr)) {
|
||
saved.append(ptr);
|
||
}
|
||
}
|
src/querybuilder.cpp | ||
---|---|---|
queries.append(superIndex);
|
||
}
|
||
queries.append(this->relationFks(entity));
|
||
qDebug() << "create index:" << entity->getTablename() << queries.size();
|
||
ok = this->database->transaction(queries);
|
||
return ok;
|
||
}
|
Auch abrufbar als: Unified diff
temporary fix for #578