merge ok [slip ci]
This commit is contained in:
commit
dfb5df6af9
|
|
@ -210,8 +210,12 @@ inline Row<T> create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Row<T> create(QObject *parent) {
|
inline T *get(T *row) {
|
||||||
return QSharedPointer<T>(new T(parent));
|
return row;
|
||||||
|
}
|
||||||
|
template<class T>
|
||||||
|
inline T *get(const QSharedPointer<T> row) {
|
||||||
|
return row.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
@ -228,6 +232,17 @@ template<class T>
|
||||||
inline Row<T> create() {
|
inline Row<T> create() {
|
||||||
return new T;
|
return new T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline T *get(const Row<T> row) {
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline T *get(const QSharedPointer<T> row) {
|
||||||
|
return row.data();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NUT_END_NAMESPACE
|
NUT_END_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ Q_OUTOFLINE_TEMPLATE RowList<T> Query<T>::toList(int count)
|
||||||
d->sql = d->database->sqlGenertor()->selectCommand(
|
d->sql = d->database->sqlGenertor()->selectCommand(
|
||||||
d->tableName, d->fieldPhrase, d->wherePhrase, d->orderPhrase,
|
d->tableName, d->fieldPhrase, d->wherePhrase, d->orderPhrase,
|
||||||
d->relations, d->skip, d->take);
|
d->relations, d->skip, d->take);
|
||||||
|
qDebug()<<d->sql;
|
||||||
QSqlQuery q = d->database->exec(d->sql);
|
QSqlQuery q = d->database->exec(d->sql);
|
||||||
if (q.lastError().isValid()) {
|
if (q.lastError().isValid()) {
|
||||||
qDebug() << q.lastError().text();
|
qDebug() << q.lastError().text();
|
||||||
|
|
@ -346,7 +346,7 @@ Q_OUTOFLINE_TEMPLATE RowList<T> Query<T>::toList(int count)
|
||||||
if (m_autoDelete)
|
if (m_autoDelete)
|
||||||
deleteLater();
|
deleteLater();
|
||||||
#endif
|
#endif
|
||||||
|
qDebug() << "len="<<returnList.count();
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
#include "tablesetbase_p.h"
|
#include "tablesetbase_p.h"
|
||||||
#include "table.h"
|
#include "table.h"
|
||||||
#include "bulkinserter.h"
|
#include "bulkinserter.h"
|
||||||
//#include "database.h"
|
|
||||||
#include "databasemodel.h"
|
#include "databasemodel.h"
|
||||||
#include "tablesetbasedata.h"
|
#include "tablesetbasedata.h"
|
||||||
|
|
||||||
|
|
@ -41,6 +40,7 @@ class Query;
|
||||||
|
|
||||||
class BulkInserter;
|
class BulkInserter;
|
||||||
class Database;
|
class Database;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class NUT_EXPORT TableSet : public TableSetBase
|
class NUT_EXPORT TableSet : public TableSetBase
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -84,20 +84,18 @@ void TableSetBase::clearChilds()
|
||||||
|
|
||||||
void TableSetBase::add(Table *t)
|
void TableSetBase::add(Table *t)
|
||||||
{
|
{
|
||||||
if(!data->tables.contains(t)){
|
if(!data->tables.contains(get(t))){
|
||||||
data.detach();
|
data.detach();
|
||||||
data->tables.insert(t);
|
data->tables.insert(get(t));
|
||||||
data->childRows.append(t);
|
data->childRows.append(get(t));
|
||||||
// data->childs.append(t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableSetBase::remove(Table *t)
|
void TableSetBase::remove(Table *t)
|
||||||
{
|
{
|
||||||
data.detach();
|
data.detach();
|
||||||
data->tables.remove(t);
|
data->tables.remove(get(t));
|
||||||
data->childRows.removeOne(t);
|
data->childRows.removeOne(get(t));
|
||||||
// data->childs.removeOne(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TableSetBase::childClassName() const
|
QString TableSetBase::childClassName() const
|
||||||
|
|
@ -112,6 +110,7 @@ Database *TableSetBase::database() const
|
||||||
|
|
||||||
void TableSetBase::setDatabase(Database *database)
|
void TableSetBase::setDatabase(Database *database)
|
||||||
{
|
{
|
||||||
|
data.detach();
|
||||||
data->database = database;
|
data->database = database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ public:
|
||||||
TableSetBaseData(Database *parent) :
|
TableSetBaseData(Database *parent) :
|
||||||
database(parent), table(nullptr)
|
database(parent), table(nullptr)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
TableSetBaseData(Table *parent) :
|
TableSetBaseData(Table *parent) :
|
||||||
database(nullptr), table(parent)
|
database(nullptr), table(parent)
|
||||||
{ }
|
{ }
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ void BasicTest::createPost()
|
||||||
comment->setMessage("comment #" + QString::number(i));
|
comment->setMessage("comment #" + QString::number(i));
|
||||||
comment->setSaveDate(QDateTime::currentDateTime());
|
comment->setSaveDate(QDateTime::currentDateTime());
|
||||||
comment->setAuthorId(user->id());
|
comment->setAuthorId(user->id());
|
||||||
newPost->comments()->append(comment);
|
db.comments()->append(comment);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
auto score = Nut::create<Score>();
|
auto score = Nut::create<Score>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue