diff --git a/src/core/qgsexpression.h b/src/core/qgsexpression.h index c3bf6fe92c57..907171104c7b 100644 --- a/src/core/qgsexpression.h +++ b/src/core/qgsexpression.h @@ -261,12 +261,12 @@ class CORE_EXPORT QgsExpression { // YEAR const value taken from postgres query // SELECT EXTRACT(EPOCH FROM interval '1 year') - static const double YEARS = ( 31557600 ); - static const double MONTHS = ( 60 * 60 * 24 * 30 ); - static const double WEEKS = ( 60 * 60 * 24 * 7 ); - static const double DAY = ( 60 * 60 * 24 ); - static const double HOUR = ( 60 * 60 ); - static const double MINUTE = ( 60 ); + static const double YEARS = 31557600; + static const double MONTHS = 60 * 60 * 24 * 30; + static const double WEEKS = 60 * 60 * 24 * 7; + static const double DAY = 60 * 60 * 24; + static const double HOUR = 60 * 60; + static const double MINUTE = 60; public: Interval( double seconds = 0 ) { mSeconds = seconds; } ~Interval(); diff --git a/tests/src/core/testqgsexpression.cpp b/tests/src/core/testqgsexpression.cpp index 52ee4998c301..358a7de24f5b 100644 --- a/tests/src/core/testqgsexpression.cpp +++ b/tests/src/core/testqgsexpression.cpp @@ -272,7 +272,7 @@ class TestQgsExpression: public QObject QTest::newRow( "condition 2 when" ) << "case when 2>3 then 23 when 3>2 then 32 else 0 end" << false << QVariant( 32 ); // Datetime functions - QTest::newRow( "to date" ) << "todate('2012-06-28')" << false << QVariant( QDate( 2012, 06, 28 ) ); + QTest::newRow( "to date" ) << "todate('2012-06-28')" << false << QVariant( QDate( 2012, 6, 28 ) ); QTest::newRow( "to interval" ) << "tointerval('1 Year 1 Month 1 Week 1 Hour 1 Minute')" << false << QVariant::fromValue( QgsExpression::Interval( 34758060 ) ); QTest::newRow( "day with date" ) << "day('2012-06-28')" << false << QVariant( 28 ); QTest::newRow( "day with interval" ) << "day(tointerval('28 days'))" << false << QVariant( 28.0 ); @@ -309,7 +309,8 @@ class TestQgsExpression: public QObject QCOMPARE( res.type(), result.type() ); switch ( res.type() ) { - case QVariant::Invalid: break; // nothing more to check + case QVariant::Invalid: + break; // nothing more to check case QVariant::Int: QCOMPARE( res.toInt(), result.toInt() ); break; @@ -330,9 +331,16 @@ class TestQgsExpression: public QObject break; case QVariant::UserType: { - QgsExpression::Interval inter = res.value(); - QgsExpression::Interval gotinter = result.value(); - QCOMPARE( inter.seconds(), gotinter.seconds() ); + if ( res.userType() == qMetaTypeId() ) + { + QgsExpression::Interval inter = res.value(); + QgsExpression::Interval gotinter = result.value(); + QCOMPARE( inter.seconds(), gotinter.seconds() ); + } + else + { + QFAIL( "unexpected user type" ); + } break; } default: