From a8feb39ab7b80886ccf1bfffae67a949f5b4f3ae Mon Sep 17 00:00:00 2001 From: Hamed Masafi Date: Mon, 26 Feb 2018 20:01:51 +0330 Subject: [PATCH] wherephrase removed [skip ci] --- src/phrase.cpp | 79 +++++-- src/phrase.h | 19 +- src/query.h | 2 +- src/wherephrase.cpp | 234 ------------------- src/wherephrase.h | 515 ------------------------------------------ test/basic/maintest.h | 2 +- 6 files changed, 82 insertions(+), 769 deletions(-) delete mode 100644 src/wherephrase.cpp delete mode 100644 src/wherephrase.h diff --git a/src/phrase.cpp b/src/phrase.cpp index e70f01b..4a00030 100644 --- a/src/phrase.cpp +++ b/src/phrase.cpp @@ -26,6 +26,12 @@ NUT_BEGIN_NAMESPACE #define LOG(s) qDebug() << __func__ << s; +PhraseData::PhraseData() : + className(""), fieldName(""), + type(Field), operatorCond(NotAssign), + left(0), right(0), operand(QVariant::Invalid), isNot(false) +{ } + PhraseData::PhraseData(const char *className, const char *fieldName) : className(className), fieldName(fieldName), type(Field), operatorCond(NotAssign), @@ -384,22 +390,67 @@ ConditionalPhrase ConditionalPhrase::operator ==(const QVariant &other) return ConditionalPhrase(this, PhraseData::Equal, other); } -ConditionalPhrase ConditionalPhrase::operator ==(const AbstractFieldPhrase &other) -{ - return ConditionalPhrase(this, PhraseData::Equal, other); +//ConditionalPhrase ConditionalPhrase::operator ==(const AbstractFieldPhrase &other) +//{ +// return ConditionalPhrase(this, PhraseData::Equal, other); +//} + +//ConditionalPhrase ConditionalPhrase::operator &&(const ConditionalPhrase &other) +//{ +// return ConditionalPhrase(this, PhraseData::And, +// const_cast(other)); +//} + +//ConditionalPhrase ConditionalPhrase::operator ||(const ConditionalPhrase &other) +//{ +// return ConditionalPhrase(this, PhraseData::Or, +// const_cast(other)); +//} + +#define DECLARE_CONDITIONALPHRASE_OPERATORS(op, cond) \ +ConditionalPhrase operator op(const ConditionalPhrase &l, const ConditionalPhrase &r) \ +{ \ + ConditionalPhrase p; \ + p.data = new PhraseData; \ + p.data->operatorCond = cond; \ + p.data->left = new PhraseData(l.data); \ + p.data->right = new PhraseData(r.data); \ + return p; \ +} \ +ConditionalPhrase operator op(const ConditionalPhrase &l, ConditionalPhrase &&r) \ +{ \ + ConditionalPhrase p; \ + p.data = new PhraseData; \ + p.data->operatorCond = cond; \ + p.data->left = new PhraseData(l.data); \ + p.data->right = r.data; \ + r.data = 0; \ + return p; \ +} \ +ConditionalPhrase operator op(ConditionalPhrase &&l, const ConditionalPhrase &r) \ +{ \ + ConditionalPhrase p; \ + p.data = new PhraseData; \ + p.data->operatorCond = cond; \ + p.data->left = l.data; \ + l.data = 0; \ + p.data->right = new PhraseData(r.data); \ + return p; \ +} \ +ConditionalPhrase operator op(ConditionalPhrase &&l, ConditionalPhrase &&r) \ +{ \ + ConditionalPhrase p; \ + p.data = new PhraseData; \ + p.data->operatorCond = cond; \ + p.data->left = l.data; \ + p.data->right = r.data; \ + l.data = r.data = 0; \ + return p; \ } -ConditionalPhrase ConditionalPhrase::operator &&(const ConditionalPhrase &other) -{ - return ConditionalPhrase(this, PhraseData::And, - const_cast(other)); -} - -ConditionalPhrase ConditionalPhrase::operator ||(const ConditionalPhrase &other) -{ - return ConditionalPhrase(this, PhraseData::Or, - const_cast(other)); -} +DECLARE_CONDITIONALPHRASE_OPERATORS(==, PhraseData::Equal) +DECLARE_CONDITIONALPHRASE_OPERATORS(||, PhraseData::Or) +DECLARE_CONDITIONALPHRASE_OPERATORS(&&, PhraseData::And) ConditionalPhrase ConditionalPhrase::operator !() { diff --git a/src/phrase.h b/src/phrase.h index 2535384..df12f7b 100644 --- a/src/phrase.h +++ b/src/phrase.h @@ -91,14 +91,15 @@ public: const char *fieldName; Type type; - Condition operatorCond; const PhraseData *left; const PhraseData *right; QVariant operand; + Condition operatorCond; bool isNot; + PhraseData(); PhraseData(const char *className, const char *fieldName); PhraseData(PhraseData *l, Condition o); PhraseData(PhraseData *l, Condition o, const PhraseData *r); @@ -186,9 +187,9 @@ public: ConditionalPhrase &operator =(const ConditionalPhrase &other); ConditionalPhrase operator ==(const QVariant &other); - ConditionalPhrase operator ==(const AbstractFieldPhrase &other); - ConditionalPhrase operator &&(const ConditionalPhrase &other); - ConditionalPhrase operator ||(const ConditionalPhrase &other); +// ConditionalPhrase operator ==(const AbstractFieldPhrase &other); +// ConditionalPhrase operator &&(const ConditionalPhrase &other); +// ConditionalPhrase operator ||(const ConditionalPhrase &other); ConditionalPhrase operator !(); SPECIALIZATION_NUMERIC_MEMBER(type, <, PhraseData::Less) @@ -197,6 +198,16 @@ public: SPECIALIZATION_NUMERIC_MEMBER(type, >=, PhraseData::GreaterEqual) }; +#define DECLARE_CONDITIONALPHRASE_OPERATORS(op) \ +ConditionalPhrase operator op(const ConditionalPhrase &l, const ConditionalPhrase &r); \ +ConditionalPhrase operator op(const ConditionalPhrase &l, ConditionalPhrase &&r); \ +ConditionalPhrase operator op(ConditionalPhrase &&l, const ConditionalPhrase &r); \ +ConditionalPhrase operator op(ConditionalPhrase &&l, ConditionalPhrase &&r); + +DECLARE_CONDITIONALPHRASE_OPERATORS(==) +DECLARE_CONDITIONALPHRASE_OPERATORS(&&) +DECLARE_CONDITIONALPHRASE_OPERATORS(||) + class AbstractFieldPhrase { public: diff --git a/src/query.h b/src/query.h index d2c7ece..29a5031 100644 --- a/src/query.h +++ b/src/query.h @@ -124,8 +124,8 @@ template Q_OUTOFLINE_TEMPLATE Query::~Query() { Q_D(Query); + qDebug() << "~Query";// << d->sql; delete d; - qDebug() << "~Query"; } template diff --git a/src/wherephrase.cpp b/src/wherephrase.cpp deleted file mode 100644 index 3a3213e..0000000 --- a/src/wherephrase.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/************************************************************************** -** -** This file is part of Nut project. -** https://github.com/HamedMasafi/Nut -** -** Nut is free software: you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** Nut is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with Nut. If not, see . -** -**************************************************************************/ - -#include -#include - -#include "phrase.h" - -NUT_BEGIN_NAMESPACE - -PhraseData::PhraseData(const char *className, const char *s) -{ - Q_UNUSED(className) - text = QString("[%1].%2").arg(className).arg(s); - type = Field; - operatorCond = NotAssign; -} - -PhraseData::PhraseData(PhraseData *l, PhraseData::Condition o) : left(l) -{ - operatorCond = o; - type = WithoutOperand; -} - -PhraseData::PhraseData(PhraseData *l, PhraseData::Condition o, - const PhraseData *r) - : left(l), right(r) -{ - operatorCond = o; - type = WithOther; -} - -PhraseData::PhraseData(PhraseData *l, PhraseData::Condition o, QVariant r) - : left(l), operand(r) -{ - operatorCond = o; - type = WithVariant; -} - -PhraseData::~PhraseData() -{ - if (type == WithOther) { - delete left; - delete right; - } - if (type == WithVariant) { - if (left) - delete left; - } -} - -PhraseData *WherePhrase::data() const -{ - return _data; -} - -WherePhrase::WherePhrase(const char *className, const char *s) -{ - _data = new PhraseData(className, s); -} - -WherePhrase::WherePhrase(const WherePhrase &l) -{ - _data = l._data; - _dataPointer = QSharedPointer(l._dataPointer); -} - -WherePhrase::WherePhrase(WherePhrase *l) -{ - _data = l->_data; - - l->_data = 0; - l->_dataPointer.reset(0); -} - -WherePhrase::WherePhrase(WherePhrase *l, PhraseData::Condition o) -{ - _data = new PhraseData(l->_data, o); - l->_data = 0; - l->_dataPointer.reset(0); -} - -WherePhrase::WherePhrase(WherePhrase *l, PhraseData::Condition o, - WherePhrase *r) -{ - _data = new PhraseData(l->_data, o, r->_data); - l->_data = 0; - r->_data = 0; - - l->_dataPointer.reset(0); - r->_dataPointer.reset(0); -} - -WherePhrase::WherePhrase(WherePhrase *l, PhraseData::Condition o, QVariant r) -{ - _data = new PhraseData(l->_data, o, r); - l->_data = 0; - l->_dataPointer.reset(0); -} - -WherePhrase::~WherePhrase() -{ -} - -WherePhrase WherePhrase::operator==(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Equal, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator!=(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::NotEqual, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator<(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Less, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator>(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Greater, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator<=(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::LessEqual, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator>=(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::GreaterEqual, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator!() -{ - if (_data->operatorCond < 20) - _data->operatorCond - = (PhraseData::Condition)((_data->operatorCond + 10) % 20); - else - qFatal("Operator ! can not aplied to non condition statements"); - - return this; // WherePhrase(this, PhraseData::Not); -} - -WherePhrase WherePhrase::operator=(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Set, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator+(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Add, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator-(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Minus, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator*(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Multiple, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator/(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Divide, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator&&(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::And, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator||(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Or, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator&(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Append, (WherePhrase *)&other); -} - -WherePhrase WherePhrase::operator==(const QVariant &other) -{ - return WherePhrase(this, PhraseData::Equal, other); -} - -WherePhrase WherePhrase::operator!=(const QVariant &other) -{ - return WherePhrase(this, PhraseData::NotEqual, other); -} - -WherePhrase WherePhrase::operator<(const QVariant &other) -{ - return WherePhrase(this, PhraseData::Less, other); -} - -WherePhrase WherePhrase::operator>(const QVariant &other) -{ - return WherePhrase(this, PhraseData::Greater, other); -} - -WherePhrase WherePhrase::operator<=(const QVariant &other) -{ - return WherePhrase(this, PhraseData::LessEqual, other); -} - -WherePhrase WherePhrase::operator>=(const QVariant &other) -{ - return WherePhrase(this, PhraseData::GreaterEqual, other); -} - - -NUT_END_NAMESPACE diff --git a/src/wherephrase.h b/src/wherephrase.h deleted file mode 100644 index 8d33b75..0000000 --- a/src/wherephrase.h +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************** -** -** This file is part of Nut project. -** https://github.com/HamedMasafi/Nut -** -** Nut is free software: you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** Nut is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with Nut. If not, see . -** -**************************************************************************/ - -#ifndef WHEREPHRASE_H -#define WHEREPHRASE_H - -#include - -#include -#include -#include -#include -#include -#include -#include "defines.h" -#include "types/dbgeography.h" - -#if __cplusplus >= 201103L -#include -#endif - -NUT_BEGIN_NAMESPACE - -class SqlGeneratorBase; -//class PhraseData -//{ -//public: -// enum Condition { -// NotAssign = 0, -// Equal, -// Less, -// LessEqual, -// Null, -// In, -// Like, - -// Not = 10, -// NotEqual, -// GreaterEqual, -// Greater, -// NotNull, -// NotIn, -// NotLike, - -// And = 20, -// Or, - -// Append, -// Set, - -// Add, -// Minus, -// Multiple, -// Divide, - -// // special types -// Distance -// }; - -// enum Type { Field, WithVariant, WithOther, WithoutOperand }; -// Type type; - -// Condition operatorCond; - -// QString text; -// const PhraseData *left; -// const PhraseData *right; -// QVariant operand; - -// PhraseData(const char *className, const char *s); -// PhraseData(PhraseData *l, Condition o); -// PhraseData(PhraseData *l, Condition o, const PhraseData *r); -// PhraseData(PhraseData *l, Condition o, QVariant r); - -// ~PhraseData(); -//}; - -class WherePhrase -{ -protected: - PhraseData *_data; - QSharedPointer _dataPointer; - -public: - WherePhrase(const char *className, const char *s); - - WherePhrase(const WherePhrase &l); - WherePhrase(WherePhrase *l); - WherePhrase(WherePhrase *l, PhraseData::Condition o); - WherePhrase(WherePhrase *l, PhraseData::Condition o, WherePhrase *r); - WherePhrase(WherePhrase *l, PhraseData::Condition o, QVariant r); - - ~WherePhrase(); - - WherePhrase operator==(const WherePhrase &other); - WherePhrase operator!=(const WherePhrase &other); - WherePhrase operator<(const WherePhrase &other); - WherePhrase operator>(const WherePhrase &other); - WherePhrase operator<=(const WherePhrase &other); - WherePhrase operator>=(const WherePhrase &other); - - WherePhrase operator==(const QVariant &other); - WherePhrase operator!=(const QVariant &other); - WherePhrase operator<(const QVariant &other); - WherePhrase operator>(const QVariant &other); - WherePhrase operator<=(const QVariant &other); - WherePhrase operator>=(const QVariant &other); - - WherePhrase operator!(); - WherePhrase operator=(const WherePhrase &other); - - WherePhrase operator+(const WherePhrase &other); - WherePhrase operator-(const WherePhrase &other); - WherePhrase operator*(const WherePhrase &other); - WherePhrase operator/(const WherePhrase &other); - - WherePhrase operator&&(const WherePhrase &other); - WherePhrase operator||(const WherePhrase &other); - - WherePhrase operator&(const WherePhrase &other); - - PhraseData *data() const; -}; - -template -class FieldPhrase : public WherePhrase -{ -public: - FieldPhrase(const char *className, const char *s); - - WherePhrase operator=(const FieldPhrase &other); - - WherePhrase operator=(const WherePhrase &other); - WherePhrase operator=(const QVariant &other); - WherePhrase operator+(const QVariant &other); - WherePhrase operator!(); - - WherePhrase operator==(const QVariant &other); - WherePhrase operator!=(const QVariant &other); - WherePhrase operator<(const QVariant &other); - WherePhrase operator>(const QVariant &other); - WherePhrase operator<=(const QVariant &other); - WherePhrase operator>=(const QVariant &other); - - WherePhrase isNull(); - WherePhrase in(QList list); - // WherePhrase in(QStringList list); - WherePhrase like(QString pattern); -}; - -template -Q_OUTOFLINE_TEMPLATE FieldPhrase::FieldPhrase(const char *className, - const char *s) - : WherePhrase(className, s) -{ - // qDebug() << "(" << this << ")" << "FieldPhrase ctor" << className << - // s; -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase:: -operator=(const QVariant &other) -{ - return WherePhrase(this, PhraseData::Set, other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase -FieldPhrase::operator=(const FieldPhrase &other) -{ - return WherePhrase(this, PhraseData::Equal, &other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase:: -operator=(const WherePhrase &other) -{ - return WherePhrase(this, PhraseData::Set, &other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase:: -operator+(const QVariant &other) -{ - return WherePhrase(this, PhraseData::Add, other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase::operator!() -{ - if (_data->operatorCond < 20) - _data->operatorCond - = (PhraseData::Condition)((_data->operatorCond + 10) % 20); - else - qFatal("Operator ! can not aplied to non condition statements"); - - return this; // WherePhrase(this, PhraseData::Not); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase:: -operator==(const QVariant &other) -{ - return WherePhrase(this, PhraseData::Equal, other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase:: -operator!=(const QVariant &other) -{ - return WherePhrase(this, PhraseData::NotEqual, other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase:: -operator<(const QVariant &other) -{ - return WherePhrase(this, PhraseData::Less, other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase:: -operator>(const QVariant &other) -{ - return WherePhrase(this, PhraseData::Greater, other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase:: -operator<=(const QVariant &other) -{ - return WherePhrase(this, PhraseData::LessEqual, other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase:: -operator>=(const QVariant &other) -{ - return WherePhrase(this, PhraseData::GreaterEqual, other); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase::isNull() -{ - return WherePhrase(this, PhraseData::Null); -} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase::in(QList list) -{ - QVariantList vlist; - foreach (T t, list) - vlist.append(QVariant::fromValue(t)); - - return WherePhrase(this, PhraseData::In, vlist); -} - -// template -// Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase::in(QStringList list) -//{ -// return WherePhrase(this, PhraseData::In, list); -//} - -template -Q_OUTOFLINE_TEMPLATE WherePhrase FieldPhrase::like(QString pattern) -{ - return WherePhrase(this, PhraseData::Like, pattern); -} - -// Custom types -template <> -class FieldPhrase : public WherePhrase -{ -public: - FieldPhrase(const char *className, const char *s) - : WherePhrase(className, s) - { - } - - WherePhrase distance(const DbGeography &geo) - { - return WherePhrase(this, PhraseData::Distance, - QVariant::fromValue(geo)); - } -}; - -// Custom types -template <> -class FieldPhrase : public WherePhrase -{ -public: - FieldPhrase(const char *className, const char *s) - : WherePhrase(className, s) - { - } - - WherePhrase distance(const QPoint &geo) - { - return WherePhrase(this, PhraseData::Distance, - QVariant::fromValue(geo)); - } - WherePhrase operator=(const QPoint &other) - { - return WherePhrase(this, PhraseData::Set, other); - } -}; - -// Custom types -template <> -class FieldPhrase : public WherePhrase -{ -public: - FieldPhrase(const char *className, const char *s) - : WherePhrase(className, s) - { - } - - WherePhrase distance(const QPointF &geo) - { - return WherePhrase(this, PhraseData::Distance, - QVariant::fromValue(geo)); - } - WherePhrase operator=(const QPointF &other) - { - return WherePhrase(this, PhraseData::Set, other); - } -}; - -// template<> -// class FieldPhrase: public WherePhrase { -// public: -// FieldPhrase(const char *className, const char* s) : WherePhrase(className, -// s){ - -// } - -// WherePhrase like(QString pattern) -// { -// return WherePhrase(this, PhraseData::Like, pattern); -// } -//}; - -template <> -class FieldPhrase : public WherePhrase -{ -public: - FieldPhrase(const char *className, const char *s) - : WherePhrase(className, s) - { - } - - WherePhrase operator==(const bool &other) - { - return WherePhrase(this, PhraseData::Equal, other ? 1 : 0); - } - - WherePhrase operator=(const bool &other) - { - return WherePhrase(this, PhraseData::Set, other ? 1 : 0); - } - - WherePhrase operator!() - { - return WherePhrase(this, PhraseData::Equal, 0); - } -}; - -class NumericFieldPhrase : public WherePhrase -{ -public: - NumericFieldPhrase(const char *className, const char *s) - : WherePhrase(className, s) - { - } - - WherePhrase operator=(const QVariant &other) - { - return WherePhrase(this, PhraseData::Set, other); - } - - WherePhrase operator+(const QVariant &other) - { - return WherePhrase(this, PhraseData::Add, other); - } - - WherePhrase operator-(const QVariant &other) - { - return WherePhrase(this, PhraseData::Minus, other); - } - - WherePhrase operator++() - { - return WherePhrase(this, PhraseData::Add, 1); - } - - WherePhrase operator--() - { - return WherePhrase(this, PhraseData::Minus, 1); - } - - WherePhrase operator==(const QVariant &other) - { - return WherePhrase(this, PhraseData::Equal, other); - } - - WherePhrase operator!=(const QVariant &other) - { - return WherePhrase(this, PhraseData::NotEqual, other); - } - - WherePhrase operator<(const QVariant &other) - { - return WherePhrase(this, PhraseData::Less, other); - } - - WherePhrase operator>(const QVariant &other) - { - return WherePhrase(this, PhraseData::Greater, other); - } - - WherePhrase operator<=(const QVariant &other) - { - return WherePhrase(this, PhraseData::LessEqual, other); - } - - WherePhrase operator>=(const QVariant &other) - { - return WherePhrase(this, PhraseData::GreaterEqual, other); - } - - WherePhrase isNull() - { - return WherePhrase(this, PhraseData::Null); - } - - template - WherePhrase in(QList list) - { - QVariantList vlist; - foreach (T t, list) - vlist.append(QVariant::fromValue(t)); - return WherePhrase(this, PhraseData::In, vlist); - } - -#if __cplusplus >= 201103L - template - WherePhrase in(std::initializer_list list) - { - return in(QList(list)); - } -#endif - - WherePhrase in(int count, ...) - { - QVariantList vlist; - - va_list ap; - va_start(ap, count); - - for (int i = 0; i < count; ++i) - vlist.append(QVariant::fromValue(va_arg(ap, int))); - - va_end(ap); - - return WherePhrase(this, PhraseData::In, vlist); - } -}; - -#define SPECIALIZATION_NUMERIC(type) \ - template <> \ - class FieldPhrase : public NumericFieldPhrase \ - { \ - public: \ - FieldPhrase(const char *className, const char *s) \ - : NumericFieldPhrase(className, s) \ - { \ - } \ - WherePhrase operator=(const WherePhrase &other) \ - { \ - return WherePhrase(this, PhraseData::Set, (WherePhrase *)&other); \ - } \ - }; - -SPECIALIZATION_NUMERIC(qint8) -SPECIALIZATION_NUMERIC(qint16) -SPECIALIZATION_NUMERIC(qint32) -SPECIALIZATION_NUMERIC(qint64) - -SPECIALIZATION_NUMERIC(quint8) -SPECIALIZATION_NUMERIC(quint16) -SPECIALIZATION_NUMERIC(quint32) -SPECIALIZATION_NUMERIC(quint64) - -SPECIALIZATION_NUMERIC(qreal) - -NUT_END_NAMESPACE - -#endif // PHRASE_H diff --git a/test/basic/maintest.h b/test/basic/maintest.h index 87eaab0..c79ce1a 100644 --- a/test/basic/maintest.h +++ b/test/basic/maintest.h @@ -27,7 +27,6 @@ private slots: void createUser(); void createPost(); void createPost2(); - void updatePostOnTheFly(); void selectPublicts(); void join(); void selectPosts(); @@ -35,6 +34,7 @@ private slots: void selectFirst(); void selectPostsWithoutTitle(); void selectPostIds(); + void updatePostOnTheFly(); void testDate(); void selectWithInvalidRelation(); void modifyPost();