From 751ae17b22506694ddba847d3dd6d25d7e2a3369 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 24 Jan 2018 23:57:44 -0500 Subject: [PATCH] TW-1947: "urgency.over" filter seems to not work correct - Thanks to Marc Richter. --- AUTHORS | 1 + ChangeLog | 2 ++ src/CLI2.cpp | 19 ++++++++++++------- test/operators.t | 20 ++++++++++++++++++++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index ab810b47e..5598ef1f2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -318,3 +318,4 @@ suggestions: Dan Callahan Martin Strunz Kai HTML + Marc Richter diff --git a/ChangeLog b/ChangeLog index b666d9357..6109fe6d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -73,6 +73,8 @@ (thanks to Paul J. Fenwick) - TW-1938 Adjust behaviour of new-uuid and new-id verbosity levels (thanks to Paul J. Fenwick) +- TW-1947 "urgency.over" filter seems to not work correct + (thanks to Marc Richter). - Added 'juhannus' as a synonym for 'midsommarafton' (thanks to Lynoure Braakman). - Deprecated the 'DUETODAY' virtual tag, which is a synonym for the 'TODAY' diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 3bd4332ab..b5719f5a6 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -1279,7 +1279,7 @@ void CLI2::desugarFilterAttributes () A2 op ("", Lexer::Type::op); op.tag ("FILTER"); - A2 rhs ("", Lexer::Type::string); + A2 rhs ("", values[0]._lextype); rhs.tag ("FILTER"); // Special case for ':'. @@ -1372,16 +1372,21 @@ void CLI2::desugarFilterAttributes () reconstructed.push_back (op); // Do not modify this construct without full understanding. - if (values.size () == 1 || ! evalSupported) + // Getting this wrong breaks a whole lot of filtering tests. + if (values.size () > 1 || evalSupported) { - if (Lexer::isDOM (rhs.attribute ("raw"))) - rhs._lextype = Lexer::Type::dom; - + for (auto& v : values) + reconstructed.push_back (v); + } + else if (Lexer::isDOM (rhs.attribute ("raw"))) + { + rhs._lextype = Lexer::Type::dom; reconstructed.push_back (rhs); } else - for (auto& v : values) - reconstructed.push_back (v); + { + reconstructed.push_back (rhs); + } found = true; } diff --git a/test/operators.t b/test/operators.t index 71642876b..91cb16ffd 100755 --- a/test/operators.t +++ b/test/operators.t @@ -269,6 +269,16 @@ class TestOperatorsQuantity(TestCase): self.assertNotIn("four", out) self.assertNotIn("five", out) + def test_urgency_over(self): + """operator urgency.over:10.0""" + code, out, err = self.t("ls urgency.over:10.0") + + self.assertIn("one", out) + self.assertIn("two", out) + self.assertNotIn("three", out) + self.assertNotIn("four", out) + self.assertNotIn("five", out) + # < operator # def test_due_before(self): @@ -331,6 +341,16 @@ class TestOperatorsQuantity(TestCase): self.assertIn("four", out) self.assertIn("five", out) + def test_urgency_under(self): + """operator urgency.under:10.0""" + code, out, err = self.t("ls urgency.under:10.0") + + self.assertNotIn("one", out) + self.assertNotIn("two", out) + self.assertIn("three", out) + self.assertIn("four", out) + self.assertIn("five", out) + # >= operator # def test_due_greater_equal(self):