MSSql and PostgreSql dose not support `

This commit is contained in:
bodhi369 2019-01-16 14:44:54 +08:00
parent e71a7ac2ed
commit dda0a5c91d
6 changed files with 24 additions and 4 deletions

View File

@ -122,5 +122,11 @@ QString PostgreSqlGenerator::diff(FieldModel *oldField, FieldModel *newField)
return sql;
}
void PostgreSqlGenerator::replaceTableNames(QString &command)
{
foreach (TableModel *m, TableModel::allModels())
command = command
.replace("[" + m->className() + "]", m->name() );
}
NUT_END_NAMESPACE

View File

@ -34,6 +34,8 @@ public:
QString fieldType(FieldModel *field);
QString diff(FieldModel *oldField, FieldModel *newField);
void replaceTableNames(QString &command);
};
NUT_END_NAMESPACE

View File

@ -128,6 +128,11 @@ public:
virtual QString phrase(const PhraseData *d) const;
virtual QString operatorString(const PhraseData::Condition &cond) const;
virtual void appendSkipTake(QString &sql, int skip = -1, int take = -1);
virtual void replaceTableNames(QString &command);
virtual void removeTableNames(QString &command);
protected:
QString createConditionalPhrase(const PhraseData *d) const;
QString createFieldPhrase(const PhraseList &ph);
@ -137,8 +142,6 @@ protected:
QString agregateText(const AgregateType &t, const QString &arg = QString()) const;
QString fromTableText(const QString &tableName, QString &joinClassName, QString &orderBy) const;
// QString createWhere(QList<WherePhrase> &wheres);
void replaceTableNames(QString &command);
void removeTableNames(QString &command);
};
NUT_END_NAMESPACE

View File

@ -141,4 +141,11 @@ void SqlServerGenerator::appendSkipTake(QString &sql, int skip, int take)
.arg(skip).arg(take));
}
void SqlServerGenerator::replaceTableNames(QString &command)
{
foreach (TableModel *m, TableModel::allModels())
command = command
.replace("[" + m->className() + "]", m->name() );
}
NUT_END_NAMESPACE

View File

@ -39,6 +39,8 @@ public:
QString escapeValue(const QVariant &v) const;
void appendSkipTake(QString &sql, int skip, int take);
void replaceTableNames(QString &command);
};
NUT_END_NAMESPACE

View File

@ -15,7 +15,7 @@ class Score : public Nut::Table
NUT_DECLARE_FIELD(int, score, score, setScore)
NUT_FOREGION_KEY(Post, int, post, post, setPost)
NUT_FOREGION_KEY(User, int, user, user, setUser)
NUT_FOREGION_KEY(User, QUuid, author, author, setAuthor)
public:
Q_INVOKABLE Score(QObject *parent = Q_NULLPTR);