From ea0496b2ee2e1c7a22356ac5eb2270a33e90a2d6 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Mon, 28 Oct 2013 11:44:28 +0100 Subject: [PATCH] Add more where operators (<, <=, >, >=) --- SqlSelect.h | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/SqlSelect.h b/SqlSelect.h index 974926b..4f4f04c 100644 --- a/SqlSelect.h +++ b/SqlSelect.h @@ -278,8 +278,6 @@ operator==( const ColumnT &, const typename ColumnT::type& value ) newCond.value = QVariant::fromValue( value ); return newCond; } - - template typename boost::enable_if, ConditionColumnLeaf >::type operator==( const ColumnT1&, const ColumnT2& ) @@ -287,7 +285,6 @@ 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 ) @@ -297,6 +294,102 @@ 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 ) +{ + 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 ) +{ + 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 ) +{ + 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; +} + /** * Create column IS NOT NULL condition. * @tparam ColumnT The column type.