Commits

Matt Chaput  committed 0e5617f

Fixed bugs in single quotes and date parser plugins. Minor docs fixes. Bumped version.

  • Participants
  • Parent commits 8a921a7

Comments (0)

Files changed (5)

File docs/source/releases/1_0.rst

 version.
 
 
+Whoosh 1.3
+==========
+
+Whoosh 1.3 adds a more efficient DATETIME field based on the new tiered NUMERIC
+field, and the DateParserPlugin. See :doc:`../dates`. 
+
+
 Whoosh 1.2
 ==========
 

File src/whoosh/__init__.py

 # limitations under the License.
 #===============================================================================
 
-__version__ = (1, 3, 0)
+__version__ = (1, 3, 1)
 
 
 def versionstring(build=True, extra=True):

File src/whoosh/qparser/dateparse.py

         
         newstream = stream.empty()
         for t in stream:
-            if t.fieldname in datefields:
-                if isinstance(t, Group):
-                    t = self.do_dates(parser, t)
-                elif isinstance(t, Word):
+            if isinstance(t, Group):
+                t = self.do_dates(parser, t)
+            elif t.fieldname in datefields:
+                if isinstance(t, Word):
                     text = t.text
                     try:
                         dt = self.dateparser.date_from(text, self.basedate)

File src/whoosh/qparser/default.py

         return ((SingleQuotesPlugin.SingleQuotes, 0), )
     
     class SingleQuotes(Token):
-        expr = re.compile(r"'([^']*?)'(?=\s|$)")
+        expr = re.compile(r"'([^']*?)'(?=\s|\]|[)}]|$)")
         
         @classmethod
         def create(cls, parser, match):

File tests/test_parse_plugins.py

         self.assertEqual(q.startdate, adatetime(2010, 3, 24).floor())
         self.assertEqual(q.enddate, adatetime(2010, 12, 12).ceil())
         
+        q = qp.parse(u"date:('30 june' OR '10 july') quick")
+        self.assertEqual(q.__class__, query.And)
+        self.assertEqual(len(q), 2)
+        self.assertEqual(q[0].__class__, query.Or)
+        self.assertEqual(q[0][0].__class__, query.DateRange)
+        self.assertEqual(q[0][1].__class__, query.DateRange)
+        
         #q = qp.parse(u"date:'to dec 12'")
         #self.assertEqual(q.__class__, query.DateRange)
         #self.assertEqual(q.startdate, None)
         self.assertEqual(q.startdate, adatetime(2010, 9, 20, 17, 10).floor())
         self.assertEqual(q.enddate, adatetime(2010, 9, 20, 17, 10).ceil())
         
+        q = qp.parse(u"(date:30 june OR date:10 july) quick")
+        self.assertEqual(q.__class__, query.And)
+        self.assertEqual(len(q), 2)
+        self.assertEqual(q[0].__class__, query.Or)
+        self.assertEqual(q[0][0].__class__, query.DateRange)
+        self.assertEqual(q[0][1].__class__, query.DateRange)
+        
     
 
 if __name__ == '__main__':