Skip to content

Commit c4f0152

Browse files
author
Richard Jones
committed
consistent text searching behaviour (AND everywhere) [SF#1101036]
1 parent 91be408 commit c4f0152

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Fixed:
1616
- issue search page allows setting of no sorting / grouping (sf bug
1717
1119475)
1818
- better edit conflict handling (sf bug 1118790)
19+
- consistent text searching behaviour (AND everywhere) (sf bug 1101036)
1920

2021

2122
2005-01-13 0.8.0b2

roundup/backends/back_anydbm.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.182 2005-01-06 17:41:10 a1s Exp $
18+
#$Id: back_anydbm.py,v 1.183 2005-02-13 22:36:59 richard Exp $
1919
'''This module defines a backend that saves the hyperdatabase in a
2020
database chosen by anydbm. It is guaranteed to always be available in python
2121
versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -1612,15 +1612,12 @@ def filter(self, search_matches, filterspec, sort=(None,None),
16121612
elif isinstance(propclass, hyperdb.String) and k != 'id':
16131613
if type(v) is not type([]):
16141614
v = [v]
1615-
m = []
16161615
for v in v:
16171616
# simple glob searching
16181617
v = re.sub(r'([\|\{\}\\\.\+\[\]\(\)])', r'\\\1', v)
16191618
v = v.replace('?', '.')
16201619
v = v.replace('*', '.*?')
1621-
m.append(v)
1622-
m = re.compile('(%s)'%('|'.join(m)), re.I)
1623-
l.append((STRING, k, m))
1620+
l.append((STRING, k, re.compile(v, re.I)))
16241621
elif isinstance(propclass, hyperdb.Date):
16251622
try:
16261623
date_rng = date.Range(v, date.Date, offset=timezone)

roundup/backends/back_metakit.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.89 2005-01-09 19:01:09 jlgijsbers Exp $
1+
# $Id: back_metakit.py,v 1.90 2005-02-13 22:37:00 richard Exp $
22
'''Metakit backend for Roundup, originally by Gordon McMillan.
33
44
Known Current Bugs:
@@ -1212,7 +1212,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
12121212
where = {'_isdel':0}
12131213
wherehigh = {}
12141214
mlcriteria = {}
1215-
regexes = {}
1215+
regexes = []
12161216
orcriteria = {}
12171217
for propname, value in filterspec.items():
12181218
prop = self.ruprops.get(propname, None)
@@ -1258,14 +1258,12 @@ def filter(self, search_matches, filterspec, sort=(None,None),
12581258
elif isinstance(prop, hyperdb.String):
12591259
if type(value) is not type([]):
12601260
value = [value]
1261-
m = []
12621261
for v in value:
12631262
# simple glob searching
12641263
v = re.sub(r'([\|\{\}\\\.\+\[\]\(\)])', r'\\\1', v)
12651264
v = v.replace('?', '.')
12661265
v = v.replace('*', '.*?')
1267-
m.append(v)
1268-
regexes[propname] = re.compile('(%s)'%('|'.join(m)), re.I)
1266+
regexes.append((propname, re.compile(v, re.I)))
12691267
elif propname == 'id':
12701268
where[propname] = int(value)
12711269
elif isinstance(prop, hyperdb.Boolean):
@@ -1353,7 +1351,7 @@ def ff(row, crit=orcriteria):
13531351

13541352
if regexes:
13551353
def ff(row, r=regexes):
1356-
for propname, regex in r.items():
1354+
for propname, regex in r:
13571355
val = str(getattr(row, propname))
13581356
if not regex.search(val):
13591357
return 0

roundup/backends/back_mysql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: back_mysql.py,v 1.54 2005-02-13 21:15:04 richard Exp $
1+
#$Id: back_mysql.py,v 1.55 2005-02-13 22:37:00 richard Exp $
22
#
33
# Copyright (c) 2003 Martynas Sklyzmantas, Andrey Lebedev <[email protected]>
44
#
@@ -573,7 +573,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
573573

574574
# now add to the where clause
575575
where.append('('
576-
+' or '.join(["_%s._%s LIKE '%s'"%(cn, k, s) for s in v])
576+
+' and '.join(["_%s._%s LIKE '%s'"%(cn, k, s) for s in v])
577577
+')')
578578
# note: args are embedded in the query string now
579579
elif isinstance(propclass, Link):

roundup/backends/rdbms_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.147 2005-01-13 05:02:19 richard Exp $
1+
# $Id: rdbms_common.py,v 1.148 2005-02-13 22:37:00 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -2103,7 +2103,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21032103

21042104
# now add to the where clause
21052105
where.append('('
2106-
+' or '.join(["_%s._%s LIKE '%s'"%(cn, k, s) for s in v])
2106+
+' and '.join(["_%s._%s LIKE '%s'"%(cn, k, s) for s in v])
21072107
+')')
21082108
# note: args are embedded in the query string now
21092109
elif isinstance(propclass, Link):

test/db_test_base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: db_test_base.py,v 1.58 2005-01-04 01:36:41 richard Exp $
18+
# $Id: db_test_base.py,v 1.59 2005-02-13 22:38:57 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint
2121

@@ -922,10 +922,14 @@ def testFilteringNumber(self):
922922
def testFilteringString(self):
923923
ae, filt = self.filteringSetup()
924924
ae(filt(None, {'title': ['one']}, ('+','id'), (None,None)), ['1'])
925+
ae(filt(None, {'title': ['issue one']}, ('+','id'), (None,None)),
926+
['1'])
927+
ae(filt(None, {'title': ['issue', 'one']}, ('+','id'), (None,None)),
928+
['1'])
925929
ae(filt(None, {'title': ['issue']}, ('+','id'), (None,None)),
926930
['1','2','3'])
927931
ae(filt(None, {'title': ['one', 'two']}, ('+','id'), (None,None)),
928-
['1', '2'])
932+
[])
929933

930934
def testFilteringLink(self):
931935
ae, filt = self.filteringSetup()

0 commit comments

Comments
 (0)