Skip to content
Permalink
Browse files

Fix dual field logic

  • Loading branch information
nyalldawson committed May 8, 2020
1 parent f8a1f37 commit 505a011d17cc7151de498d17d378f31f93a8bc0a
@@ -194,11 +194,11 @@ QString QgsVectorLayerTemporalProperties::createFilterString( QgsVectorLayer *,

case ModeFeatureDateTimeStartAndEndFromFields:
return QStringLiteral( "%1 %2 %3 AND %4 %5 %6" ).arg( QgsExpression::quotedColumnRef( mStartFieldName ),
range.includeBeginning() ? QStringLiteral( ">=" ) : QStringLiteral( ">" ),
dateTimeExpressionLiteral( range.begin() ),
QgsExpression::quotedColumnRef( mEndFieldName ),
range.includeEnd() ? QStringLiteral( "<=" ) : QStringLiteral( "<" ),
dateTimeExpressionLiteral( range.end() ) );
dateTimeExpressionLiteral( range.end() ),
QgsExpression::quotedColumnRef( mEndFieldName ),
range.includeBeginning() ? QStringLiteral( ">=" ) : QStringLiteral( ">" ),
dateTimeExpressionLiteral( range.begin() ) );
}

return QString();
@@ -101,13 +101,13 @@ def testDualFieldMode(self):
self.assertFalse(props.createFilterString(layer, range))

props.setIsActive(True)
self.assertEqual(props.createFilterString(layer, range), '"start_field" >= make_datetime(2019,3,4,11,12,13) AND "end_field" <= make_datetime(2020,5,6,8,9,10)')
self.assertEqual(props.createFilterString(layer, range), '"start_field" <= make_datetime(2020,5,6,8,9,10) AND "end_field" >= make_datetime(2019,3,4,11,12,13)')

range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)), QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeBeginning=False)
self.assertEqual(props.createFilterString(layer, range), '"start_field" > make_datetime(2019,3,4,11,12,13) AND "end_field" <= make_datetime(2020,5,6,8,9,10)')
self.assertEqual(props.createFilterString(layer, range), '"start_field" <= make_datetime(2020,5,6,8,9,10) AND "end_field" > make_datetime(2019,3,4,11,12,13)')

range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)), QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeEnd=False)
self.assertEqual(props.createFilterString(layer, range), '"start_field" >= make_datetime(2019,3,4,11,12,13) AND "end_field" < make_datetime(2020,5,6,8,9,10)')
self.assertEqual(props.createFilterString(layer, range), '"start_field" < make_datetime(2020,5,6,8,9,10) AND "end_field" >= make_datetime(2019,3,4,11,12,13)')


if __name__ == '__main__':

0 comments on commit 505a011

Please sign in to comment.
You can’t perform that action at this time.