diff --git a/orm_lib/inc/drogon/orm/Criteria.h b/orm_lib/inc/drogon/orm/Criteria.h index 5b1aa398..2b761df3 100644 --- a/orm_lib/inc/drogon/orm/Criteria.h +++ b/orm_lib/inc/drogon/orm/Criteria.h @@ -40,6 +40,7 @@ enum class CompareOperator LE, Like, In, + NotIn, IsNull, IsNotNull }; @@ -107,8 +108,6 @@ class DROGON_EXPORT Criteria case CompareOperator::Like: conditionString_ += " like $?"; break; - case CompareOperator::IsNull: - case CompareOperator::IsNotNull: default: break; } @@ -123,11 +122,21 @@ class DROGON_EXPORT Criteria const CompareOperator &opera, const std::vector &args) { - assert(opera == CompareOperator::In && args.size() > 0); - conditionString_ = colName + " in ("; - for (size_t i = 0; i < args.size(); ++i) + const auto argsSize = args.size(); + assert(((opera == CompareOperator::In) || + (opera == CompareOperator::NotIn)) && + (argsSize > 0)); + if (opera == CompareOperator::In) { - if (i < args.size() - 1) + conditionString_ = colName + " in ("; + } + else if (opera == CompareOperator::NotIn) + { + conditionString_ = colName + " not in ("; + } + for (size_t i = 0; i < argsSize; ++i) + { + if (i < (argsSize - 1)) conditionString_.append("$?,"); else conditionString_.append("$?"); @@ -146,11 +155,21 @@ class DROGON_EXPORT Criteria const CompareOperator &opera, std::vector &&args) { - assert(opera == CompareOperator::In && args.size() > 0); - conditionString_ = colName + " in ("; - for (size_t i = 0; i < args.size(); ++i) + const auto argsSize = args.size(); + assert(((opera == CompareOperator::In) || + (opera == CompareOperator::NotIn)) && + (argsSize > 0)); + if (opera == CompareOperator::In) { - if (i < args.size() - 1) + conditionString_ = colName + " in ("; + } + else if (opera == CompareOperator::NotIn) + { + conditionString_ = colName + " not in ("; + } + for (size_t i = 0; i < argsSize; ++i) + { + if (i < (argsSize - 1)) conditionString_.append("$?,"); else conditionString_.append("$?");