continue
This commit is contained in:
parent
27a8908e26
commit
070254bd02
|
|
@ -86,15 +86,15 @@ QVariant Table::primaryValue() const
|
||||||
void Table::propertyChanged(const QString &propName)
|
void Table::propertyChanged(const QString &propName)
|
||||||
{
|
{
|
||||||
Q_D(Table);
|
Q_D(Table);
|
||||||
// if (!d->model)
|
if (!d->model)
|
||||||
// d->model = TableModel::findByClassName(metaObject()->className());
|
d->model = TableModel::findByClassName(metaObject()->className());
|
||||||
|
|
||||||
// if (!d->model)
|
if (!d->model)
|
||||||
// qFatal ("model for class '%s' not found", qPrintable(metaObject()->className()));
|
qFatal ("model for class '%s' not found", qPrintable(metaObject()->className()));
|
||||||
|
|
||||||
// foreach (FieldModel *f, d->model->fields())
|
foreach (FieldModel *f, d->model->fields())
|
||||||
// if(f->isPrimaryKey && propName == f->name && f->isAutoIncrement)
|
if(f->isPrimaryKey && propName == f->name && f->isAutoIncrement)
|
||||||
// return;
|
return;
|
||||||
|
|
||||||
d->changedProperties.insert(propName);
|
d->changedProperties.insert(propName);
|
||||||
if (d->status == FeatchedFromDB)
|
if (d->status == FeatchedFromDB)
|
||||||
|
|
@ -122,6 +122,9 @@ bool Table::setParentTable(Table *master)
|
||||||
|
|
||||||
QString masterClassName = master->metaObject()->className();
|
QString masterClassName = master->metaObject()->className();
|
||||||
|
|
||||||
|
if (!d->model)
|
||||||
|
d->model = TableModel::findByClassName(metaObject()->className());
|
||||||
|
|
||||||
foreach (RelationModel *r, d->model->foregionKeys())
|
foreach (RelationModel *r, d->model->foregionKeys())
|
||||||
if(r->masterClassName == masterClassName)
|
if(r->masterClassName == masterClassName)
|
||||||
{
|
{
|
||||||
|
|
@ -164,7 +167,7 @@ int Table::save(Database *db)
|
||||||
|
|
||||||
QSqlQuery q = db->exec(db->sqlGenertor()->saveRecord(this, db->tableName(metaObject()->className())));
|
QSqlQuery q = db->exec(db->sqlGenertor()->saveRecord(this, db->tableName(metaObject()->className())));
|
||||||
|
|
||||||
auto model = db->model().tableByName(metaObject()->className());
|
auto model = db->model().tableByClassName(metaObject()->className());
|
||||||
if(status() == Added && model->isPrimaryKeyAutoIncrement())
|
if(status() == Added && model->isPrimaryKeyAutoIncrement())
|
||||||
setProperty(model->primaryKey().toLatin1().data(), q.lastInsertId());
|
setProperty(model->primaryKey().toLatin1().data(), q.lastInsertId());
|
||||||
|
|
||||||
|
|
@ -190,7 +193,7 @@ void Table::setStatus(const Status &status)
|
||||||
|
|
||||||
|
|
||||||
TablePrivate::TablePrivate(Table *parent) : q_ptr(parent),
|
TablePrivate::TablePrivate(Table *parent) : q_ptr(parent),
|
||||||
status(Table::NewCreated), parentTableSet(nullptr)
|
model(nullptr), status(Table::NewCreated), parentTableSet(nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -274,8 +274,8 @@ void BasicTest::emptyDatabase()
|
||||||
|
|
||||||
void BasicTest::cleanupTestCase()
|
void BasicTest::cleanupTestCase()
|
||||||
{
|
{
|
||||||
post->deleteLater();
|
// post->deleteLater();
|
||||||
user->deleteLater();
|
// user->deleteLater();
|
||||||
|
|
||||||
//release models before exiting
|
//release models before exiting
|
||||||
// qDeleteAll(TableModel::allModels());
|
// qDeleteAll(TableModel::allModels());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue