diff --git a/SqlSelect.h b/SqlSelect.h index 4f4f04c..3c51bbd 100644 --- a/SqlSelect.h +++ b/SqlSelect.h @@ -294,6 +294,30 @@ operator==( const ColumnT1& , const placeholder &p ) return c; } +template +typename boost::enable_if >::type +operator!=( const ColumnT &, const typename ColumnT::type& value ) +{ + ConditionValueLeaf newCond; + newCond.value = QVariant::fromValue( value ); + return newCond; +} +template +typename boost::enable_if, ConditionColumnLeaf >::type +operator!=( const ColumnT1&, const ColumnT2& ) +{ + BOOST_MPL_ASSERT(( boost::is_same )); // only compare columns of the same type + return ConditionColumnLeaf(); +} +template +typename boost::enable_if >::type +operator!=( const ColumnT1& , const placeholder &p ) +{ + ConditionPlaceholderLeaf c; + c.placeholder = p.m_name; + return c; +} + template typename boost::enable_if >::type operator<( const ColumnT &, const typename ColumnT::type& value ) diff --git a/tests/selecttest.cpp b/tests/selecttest.cpp index bd330f6..c947611 100644 --- a/tests/selecttest.cpp +++ b/tests/selecttest.cpp @@ -34,6 +34,11 @@ private Q_SLOTS: << "SELECT tblPerson.id FROM tblPerson WHERE tblPerson.HireRights = :0" << (QVector() << true); + QTest::newRow( "single condition, not equal" ) + << select( Person.id ).from( Person ).where( Person.HireRights != true ).queryBuilder() + << "SELECT tblPerson.id FROM tblPerson WHERE tblPerson.HireRights <> :0" + << (QVector() << true); + QTest::newRow( "single condition, less than" ) << select( Person.id ).from( Person ).where( Person.Hired < QDateTime( QDate( 2013, 10, 28 ) )).queryBuilder() << "SELECT tblPerson.id FROM tblPerson WHERE tblPerson.Hired < :0"