some polish and #21 [skip ci]
This commit is contained in:
parent
fed16055bc
commit
e4f1c4c266
|
|
@ -203,8 +203,8 @@ bool DatabasePrivate::getCurrectScheema()
|
||||||
QString name;
|
QString name;
|
||||||
QString value;
|
QString value;
|
||||||
|
|
||||||
if (!checkClassInfo(q->metaObject()->classInfo(i),
|
if (!nutClassInfoString(q->metaObject()->classInfo(i),
|
||||||
type, name, value)) {
|
type, name, value)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,21 +249,21 @@ bool DatabasePrivate::getCurrectScheema()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabasePrivate::checkClassInfo(const QMetaClassInfo &classInfo, QString &type, QString &name, QString &value)
|
//bool DatabasePrivate::checkClassInfo(const QMetaClassInfo &classInfo, QString &type, QString &name, QString &value)
|
||||||
{
|
//{
|
||||||
if (!QString(classInfo.name()).startsWith(__nut_NAME_PERFIX)) {
|
// if (!QString(classInfo.name()).startsWith(__nut_NAME_PERFIX)) {
|
||||||
return false;
|
// return false;
|
||||||
} else {
|
// } else {
|
||||||
QStringList parts = QString(classInfo.value()).split("\n");
|
// QStringList parts = QString(classInfo.value()).split("\n");
|
||||||
if (parts.count() != 3)
|
// if (parts.count() != 3)
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
type = parts[0];
|
// type = parts[0];
|
||||||
name = parts[1];
|
// name = parts[1];
|
||||||
value = parts[2];
|
// value = parts[2];
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
DatabaseModel DatabasePrivate::getLastScheema()
|
DatabaseModel DatabasePrivate::getLastScheema()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ public:
|
||||||
DatabaseModel getLastScheema();
|
DatabaseModel getLastScheema();
|
||||||
bool getCurrectScheema();
|
bool getCurrectScheema();
|
||||||
|
|
||||||
bool checkClassInfo(const QMetaClassInfo &classInfo,
|
// bool checkClassInfo(const QMetaClassInfo &classInfo,
|
||||||
QString &type, QString &name, QString &value);
|
// QString &type, QString &name, QString &value);
|
||||||
QSqlDatabase db;
|
QSqlDatabase db;
|
||||||
|
|
||||||
QString hostName;
|
QString hostName;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@
|
||||||
#include "defines_p.h"
|
#include "defines_p.h"
|
||||||
#include "qglobal.h"
|
#include "qglobal.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QMetaClassInfo>
|
||||||
|
|
||||||
#ifdef NUT_COMPILE_STATIC
|
#ifdef NUT_COMPILE_STATIC
|
||||||
# define NUT_EXPORT
|
# define NUT_EXPORT
|
||||||
#else
|
#else
|
||||||
|
|
@ -36,21 +41,95 @@
|
||||||
Q_CLASSINFO(__nut_NAME_PERFIX type #name #value, \
|
Q_CLASSINFO(__nut_NAME_PERFIX type #name #value, \
|
||||||
type "\n" #name "\n" #value)
|
type "\n" #name "\n" #value)
|
||||||
|
|
||||||
|
#define NUT_INFO_STRING(type, name, value) \
|
||||||
|
Q_CLASSINFO(__nut_NAME_PERFIX type #name #value, \
|
||||||
|
type "\n" #name "\n" value)
|
||||||
|
|
||||||
|
inline bool nutClassInfo(const QMetaClassInfo &classInfo,
|
||||||
|
QString &type, QString &name, QVariant &value)
|
||||||
|
{
|
||||||
|
if (!QString(classInfo.name()).startsWith(__nut_NAME_PERFIX)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
QStringList parts = QString(classInfo.value()).split("\n");
|
||||||
|
if (parts.count() != 3)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
type = parts[0];
|
||||||
|
name = parts[1];
|
||||||
|
value = qVariantFromValue(parts[2]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool nutClassInfoString(const QMetaClassInfo &classInfo,
|
||||||
|
QString &type, QString &name, QString &value)
|
||||||
|
{
|
||||||
|
if (!QString(classInfo.name()).startsWith(__nut_NAME_PERFIX)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
QStringList parts = QString(classInfo.value()).split("\n");
|
||||||
|
if (parts.count() != 3)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
type = parts[0];
|
||||||
|
name = parts[1];
|
||||||
|
value = parts[2];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool nutClassInfoBool(const QMetaClassInfo &classInfo,
|
||||||
|
QString &type, QString &name, bool &value)
|
||||||
|
{
|
||||||
|
if (!QString(classInfo.name()).startsWith(__nut_NAME_PERFIX)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
QStringList parts = QString(classInfo.value()).split("\n");
|
||||||
|
if (parts.count() != 3)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QString buffer = parts[2].toLower();
|
||||||
|
if (buffer != "true" && buffer != "false")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
type = parts[0];
|
||||||
|
name = parts[1];
|
||||||
|
value = (buffer == "true");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool nutClassInfoInt(const QMetaClassInfo &classInfo,
|
||||||
|
QString &type, QString &name, bool &value)
|
||||||
|
{
|
||||||
|
if (!QString(classInfo.name()).startsWith(__nut_NAME_PERFIX)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
QStringList parts = QString(classInfo.value()).split("\n");
|
||||||
|
if (parts.count() != 3)
|
||||||
|
return false;
|
||||||
|
bool ok;
|
||||||
|
type = parts[0];
|
||||||
|
name = parts[1];
|
||||||
|
value = parts[2].toInt(&ok);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
#define NUT_DB_VERSION(version) \
|
#define NUT_DB_VERSION(version) \
|
||||||
NUT_INFO(__nut_DB_VERSION, version, 0)
|
NUT_INFO(__nut_DB_VERSION, version, 0)
|
||||||
|
|
||||||
#define NUT_DECLARE_TABLE(type, name) \
|
#define NUT_DECLARE_TABLE(type, name) \
|
||||||
NUT_INFO(__nut_TABLE, type, name) \
|
NUT_INFO(__nut_TABLE, type, name) \
|
||||||
Q_PROPERTY(type* name READ name) \
|
Q_PROPERTY(NUT_WRAP_NAMESPACE(TableSet<type>) name READ name) \
|
||||||
Q_PROPERTY(NUT_WRAP_NAMESPACE(TableSet<type>) name##Table READ name##Table)\
|
NUT_WRAP_NAMESPACE(TableSet<type>) *m_##name; \
|
||||||
type* m_##name; \
|
|
||||||
NUT_WRAP_NAMESPACE(TableSet<type>) *m_##name##Table; \
|
|
||||||
public: \
|
public: \
|
||||||
static const type _##name; \
|
static const type *_##name; \
|
||||||
type* name() const{ return m_##name; } \
|
NUT_WRAP_NAMESPACE(TableSet<type>) *name() const \
|
||||||
NUT_WRAP_NAMESPACE(TableSet<type>) *name##Table() const \
|
{ return m_##name; }
|
||||||
{ return m_##name##Table; }
|
|
||||||
|
|
||||||
//Table
|
//Table
|
||||||
#define NUT_DECLARE_FIELD(type, name, read, write) \
|
#define NUT_DECLARE_FIELD(type, name, read, write) \
|
||||||
|
|
@ -99,11 +178,9 @@ public: \
|
||||||
return m_##n; \
|
return m_##n; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define NUT_PRIMARY_KEY(x) NUT_INFO(__nut_PRIMARY_KEY, x, 0)
|
#define NUT_PRIMARY_KEY(x) NUT_INFO(__nut_PRIMARY_KEY, x, 0)
|
||||||
#define NUT_AUTO_INCREMENT(x) NUT_INFO(__nut_AUTO_INCREMENT, x, 0)
|
#define NUT_AUTO_INCREMENT(x) NUT_INFO(__nut_AUTO_INCREMENT, x, 0)
|
||||||
#define NUT_PRIMARY_AUTO_INCREMENT(x) NUT_PRIMARY_KEY(x) \
|
#define NUT_PRIMARY_AUTO_INCREMENT(x) NUT_INFO(__nut_PRIMARY_KEY_AI, x, 0)
|
||||||
NUT_AUTO_INCREMENT(x)
|
|
||||||
#define NUT_DISPLAY_NAME(field, name) NUT_INFO(__nut_DISPLAY, field, name)
|
#define NUT_DISPLAY_NAME(field, name) NUT_INFO(__nut_DISPLAY, field, name)
|
||||||
#define NUT_UNIQUE(x) NUT_INFO(__nut_UNIQUE, x, 0)
|
#define NUT_UNIQUE(x) NUT_INFO(__nut_UNIQUE, x, 0)
|
||||||
#define NUT_LEN(field, len) NUT_INFO(__nut_LEN, field, len)
|
#define NUT_LEN(field, len) NUT_INFO(__nut_LEN, field, len)
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,11 @@
|
||||||
#define __FOREIGN_KEYS "foreign_keys"
|
#define __FOREIGN_KEYS "foreign_keys"
|
||||||
#define __nut_FIELD "field"
|
#define __nut_FIELD "field"
|
||||||
|
|
||||||
|
#define __nut_NAME_PERFIX "nut_info::"
|
||||||
#define __nut_DB_VERSION "database_version"
|
#define __nut_DB_VERSION "database_version"
|
||||||
#define __nut_NAME_PERFIX "nut_db_key::"
|
|
||||||
#define __nut_PRIMARY_KEY "primary_key"
|
#define __nut_PRIMARY_KEY "primary_key"
|
||||||
#define __nut_AUTO_INCREMENT "auto_increment"
|
#define __nut_AUTO_INCREMENT "auto_increment"
|
||||||
|
#define __nut_PRIMARY_KEY_AI "primary_key_ai"
|
||||||
#define __nut_UNIQUE "unique"
|
#define __nut_UNIQUE "unique"
|
||||||
#define __nut_TABLE "table"
|
#define __nut_TABLE "table"
|
||||||
#define __nut_TABLE_NAME "table_name"
|
#define __nut_TABLE_NAME "table_name"
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ QString PostgreSqlGenerator::fieldType(FieldModel *field)
|
||||||
if(field->isAutoIncrement)
|
if(field->isAutoIncrement)
|
||||||
dbType = "BIGSERIAL";
|
dbType = "BIGSERIAL";
|
||||||
else
|
else
|
||||||
dbType = "BIGINTEGER";
|
dbType = "BIGINT";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QVariant::Double:
|
case QVariant::Double:
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
NUT_BEGIN_NAMESPACE
|
NUT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
#define LOG(s) qDebug() << __func__ << s
|
|
||||||
|
|
||||||
PhraseData::PhraseData() :
|
PhraseData::PhraseData() :
|
||||||
className(""), fieldName(""),
|
className(""), fieldName(""),
|
||||||
type(Field), operatorCond(NotAssign),
|
type(Field), operatorCond(NotAssign),
|
||||||
|
|
@ -65,7 +63,6 @@ PhraseData::PhraseData(PhraseData *l, PhraseData::Condition o, QVariant r)
|
||||||
|
|
||||||
PhraseData *PhraseData::operator =(PhraseData *other)
|
PhraseData *PhraseData::operator =(PhraseData *other)
|
||||||
{
|
{
|
||||||
LOG("");
|
|
||||||
other->parents++;
|
other->parents++;
|
||||||
return other;
|
return other;
|
||||||
}
|
}
|
||||||
|
|
@ -76,20 +73,6 @@ PhraseData &PhraseData::operator =(PhraseData &other)
|
||||||
return other;
|
return other;
|
||||||
}
|
}
|
||||||
|
|
||||||
//PhraseData::PhraseData(const PhraseData &other) :
|
|
||||||
// left(other.left), right(other.right), operand(other.operand),
|
|
||||||
// operatorCond(other.operatorCond), className(other.className),
|
|
||||||
// fieldName(other.fieldName), type(other.type), isNot(other.isNot),
|
|
||||||
// parents(other.parents + 1)
|
|
||||||
//{ }
|
|
||||||
|
|
||||||
//PhraseData::PhraseData(const PhraseData *other) :
|
|
||||||
// left(other->left), right(other->right), operand(other->operand),
|
|
||||||
// operatorCond(other->operatorCond), className(other->className),
|
|
||||||
// fieldName(other->fieldName), type(other->type), isNot(other->isNot),
|
|
||||||
// parents(other->parents + 1)
|
|
||||||
//{ }
|
|
||||||
|
|
||||||
QString PhraseData::toString() const
|
QString PhraseData::toString() const
|
||||||
{
|
{
|
||||||
return QString("[%1].%2").arg(className).arg(fieldName);
|
return QString("[%1].%2").arg(className).arg(fieldName);
|
||||||
|
|
@ -97,27 +80,10 @@ QString PhraseData::toString() const
|
||||||
|
|
||||||
PhraseData::~PhraseData()
|
PhraseData::~PhraseData()
|
||||||
{
|
{
|
||||||
// if (type == WithOther) {
|
|
||||||
// delete left;
|
|
||||||
// delete right;
|
|
||||||
// }
|
|
||||||
// if (type == WithVariant) {
|
|
||||||
// if (left)
|
|
||||||
// delete left;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (right && !--right->parents)
|
|
||||||
// delete right;
|
|
||||||
|
|
||||||
// if (left && !--left->parents)
|
|
||||||
// delete left;
|
|
||||||
|
|
||||||
LOG("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhraseData::cleanUp()
|
void PhraseData::cleanUp()
|
||||||
{
|
{
|
||||||
// cleanUp(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhraseData::cleanUp(PhraseData *d)
|
void PhraseData::cleanUp(PhraseData *d)
|
||||||
|
|
@ -154,12 +120,6 @@ AbstractFieldPhrase::AbstractFieldPhrase(AbstractFieldPhrase &&other)
|
||||||
|
|
||||||
AbstractFieldPhrase::~AbstractFieldPhrase()
|
AbstractFieldPhrase::~AbstractFieldPhrase()
|
||||||
{
|
{
|
||||||
if (data) {
|
|
||||||
LOG(data->toString()) << data->parents;
|
|
||||||
} else {
|
|
||||||
LOG("");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
--data->parents;
|
--data->parents;
|
||||||
if (data->parents <= 0)
|
if (data->parents <= 0)
|
||||||
|
|
@ -232,14 +192,12 @@ PhraseList::PhraseList() : isValid(false)
|
||||||
|
|
||||||
PhraseList::PhraseList(const PhraseList &other) : isValid(true)
|
PhraseList::PhraseList(const PhraseList &other) : isValid(true)
|
||||||
{
|
{
|
||||||
LOG("");
|
|
||||||
data = qMove(other.data);
|
data = qMove(other.data);
|
||||||
const_cast<PhraseList&>(other).data.clear();
|
const_cast<PhraseList&>(other).data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
PhraseList::PhraseList(PhraseList &&other)
|
PhraseList::PhraseList(PhraseList &&other)
|
||||||
{
|
{
|
||||||
LOG("");
|
|
||||||
data = other.data;
|
data = other.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,7 +235,6 @@ PhraseList::PhraseList(PhraseList *left, const AbstractFieldPhrase *right)
|
||||||
|
|
||||||
PhraseList::~PhraseList()
|
PhraseList::~PhraseList()
|
||||||
{
|
{
|
||||||
LOG("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PhraseList &PhraseList::operator =(const PhraseList &other)
|
PhraseList &PhraseList::operator =(const PhraseList &other)
|
||||||
|
|
@ -484,7 +441,6 @@ ConditionalPhrase::ConditionalPhrase(ConditionalPhrase *l,
|
||||||
|
|
||||||
ConditionalPhrase::~ConditionalPhrase()
|
ConditionalPhrase::~ConditionalPhrase()
|
||||||
{
|
{
|
||||||
LOG("");
|
|
||||||
if (data) {
|
if (data) {
|
||||||
data->cleanUp();
|
data->cleanUp();
|
||||||
if (!--data->parents)
|
if (!--data->parents)
|
||||||
|
|
|
||||||
|
|
@ -156,22 +156,22 @@ bool TableModel::operator !=(const TableModel &t) const
|
||||||
return !(*this == t);
|
return !(*this == t);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TableModel::checkClassInfo(const QMetaClassInfo &classInfo,
|
//bool TableModel::checkClassInfo(const QMetaClassInfo &classInfo,
|
||||||
QString &type, QString &name, QString &value)
|
// QString &type, QString &name, QString &value)
|
||||||
{
|
//{
|
||||||
if (!QString(classInfo.name()).startsWith(__nut_NAME_PERFIX)) {
|
// if (!QString(classInfo.name()).startsWith(__nut_NAME_PERFIX)) {
|
||||||
return false;
|
// return false;
|
||||||
} else {
|
// } else {
|
||||||
QStringList parts = QString(classInfo.value()).split("\n");
|
// QStringList parts = QString(classInfo.value()).split("\n");
|
||||||
if (parts.count() != 3)
|
// if (parts.count() != 3)
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
type = parts[0];
|
// type = parts[0];
|
||||||
name = parts[1];
|
// name = parts[1];
|
||||||
value = parts[2];
|
// value = parts[2];
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
TableModel::TableModel(int typeId, QString tableName)
|
TableModel::TableModel(int typeId, QString tableName)
|
||||||
{
|
{
|
||||||
|
|
@ -196,7 +196,7 @@ TableModel::TableModel(int typeId, QString tableName)
|
||||||
QString name;
|
QString name;
|
||||||
QString value;
|
QString value;
|
||||||
|
|
||||||
if (!checkClassInfo(tableMetaObject->classInfo(j),
|
if (!nutClassInfoString(tableMetaObject->classInfo(j),
|
||||||
type, name, value)) {
|
type, name, value)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -227,7 +227,7 @@ TableModel::TableModel(int typeId, QString tableName)
|
||||||
QString name;
|
QString name;
|
||||||
QString value;
|
QString value;
|
||||||
|
|
||||||
if (!checkClassInfo(tableMetaObject->classInfo(j),
|
if (!nutClassInfoString(tableMetaObject->classInfo(j),
|
||||||
type, name, value)) {
|
type, name, value)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -248,23 +248,27 @@ TableModel::TableModel(int typeId, QString tableName)
|
||||||
|
|
||||||
|
|
||||||
FieldModel *f = field(name);
|
FieldModel *f = field(name);
|
||||||
if(!f)
|
if (!f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(type == __nut_LEN)
|
if (type == __nut_LEN)
|
||||||
f->length = value.toInt();
|
f->length = value.toInt();
|
||||||
else if(type == __nut_NOT_NULL)
|
else if (type == __nut_NOT_NULL)
|
||||||
f->notNull = true;
|
f->notNull = true;
|
||||||
else if(type == __nut_DEFAULT_VALUE)
|
else if (type == __nut_DEFAULT_VALUE)
|
||||||
f->defaultValue = value;
|
f->defaultValue = value;
|
||||||
else if(type == __nut_PRIMARY_KEY)
|
else if (type == __nut_PRIMARY_KEY)
|
||||||
f->isPrimaryKey = true;
|
f->isPrimaryKey = true;
|
||||||
else if(type == __nut_AUTO_INCREMENT)
|
else if (type == __nut_AUTO_INCREMENT)
|
||||||
f->isAutoIncrement = true;
|
f->isAutoIncrement = true;
|
||||||
else if(type == __nut_UNIQUE)
|
else if (type == __nut_UNIQUE)
|
||||||
f->isUnique = true;
|
f->isUnique = true;
|
||||||
else if(type == __nut_DISPLAY)
|
else if (type == __nut_DISPLAY)
|
||||||
f->displayName = value.mid(1, value.length() - 2);
|
f->displayName = value.mid(1, value.length() - 2);
|
||||||
|
else if (type == __nut_PRIMARY_KEY_AI) {
|
||||||
|
f->isPrimaryKey = true;
|
||||||
|
f->isAutoIncrement = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!findByTypeId(typeId) && !tableName.isNull())
|
if(!findByTypeId(typeId) && !tableName.isNull())
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,8 @@ private:
|
||||||
QList<FieldModel*> _fields;
|
QList<FieldModel*> _fields;
|
||||||
QList<RelationModel*> _foreignKeys;
|
QList<RelationModel*> _foreignKeys;
|
||||||
static QSet<TableModel*>_allModels;
|
static QSet<TableModel*>_allModels;
|
||||||
bool checkClassInfo(const QMetaClassInfo &classInfo,
|
// bool checkClassInfo(const QMetaClassInfo &classInfo,
|
||||||
QString &type, QString &name, QString &value);
|
// QString &type, QString &name, QString &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
NUT_END_NAMESPACE
|
NUT_END_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
|
#include <QtCore/QUuid>
|
||||||
#include "table.h"
|
#include "table.h"
|
||||||
|
|
||||||
#ifdef NUT_NAMESPACE
|
#ifdef NUT_NAMESPACE
|
||||||
|
|
@ -16,13 +17,13 @@ class Comment : public Table
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
NUT_PRIMARY_AUTO_INCREMENT(id)
|
NUT_PRIMARY_AUTO_INCREMENT(id)
|
||||||
NUT_DECLARE_FIELD(int, id, id, setId)
|
NUT_DECLARE_FIELD(QUuid, id, id, setId)
|
||||||
NUT_DECLARE_FIELD(QString, message, message, setMessage)
|
NUT_DECLARE_FIELD(QString, message, message, setMessage)
|
||||||
NUT_DECLARE_FIELD(QDateTime, saveDate, saveDate, setSaveDate)
|
NUT_DECLARE_FIELD(QDateTime, saveDate, saveDate, setSaveDate)
|
||||||
NUT_DECLARE_FIELD(qreal, point, point, setPoint)
|
NUT_DECLARE_FIELD(qreal, point, point, setPoint)
|
||||||
|
|
||||||
NUT_FOREGION_KEY(Post, int, post, post, setPost)
|
NUT_FOREGION_KEY(Post, int, post, post, setPost)
|
||||||
NUT_FOREGION_KEY(User, int, author, author, setAuthor)
|
NUT_FOREGION_KEY(User, QUuid, author, author, setAuthor)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE explicit Comment(QObject *parentTableSet = 0);
|
Q_INVOKABLE explicit Comment(QObject *parentTableSet = 0);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#define DRIVER "QSQLITE"
|
#define DRIVER "QSQLITE"
|
||||||
#define HOST "127.0.0.1"
|
#define HOST "127.0.0.1"
|
||||||
#define DATABASE "nutdb"
|
#define DATABASE "nutdb1"
|
||||||
#define USERNAME "root"
|
#define USERNAME "root"
|
||||||
#define PASSWORD "onlyonlyi"
|
#define PASSWORD "onlyonlyi"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ class User : public Nut::Table
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
NUT_PRIMARY_AUTO_INCREMENT(id)
|
NUT_PRIMARY_KEY(id)
|
||||||
NUT_DECLARE_FIELD(int, id, id, setId)
|
NUT_DECLARE_FIELD(QUuid, id, id, setId)
|
||||||
|
|
||||||
NUT_NOT_NULL(username)
|
NUT_NOT_NULL(username)
|
||||||
NUT_LEN(username, 50)
|
NUT_LEN(username, 50)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue