Skip to content

Commit c72952d

Browse files
committed
feat(dev): datatables special chars;
- Search with special characters in datatables view.
1 parent 1055e3c commit c72952d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ckanext/datatablesview/blueprint.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,22 @@ def ajax(resource_view_id: str):
9292
v = str(request.form[u'columns[%d][search][value]' % i])
9393
if v:
9494
k = str(request.form[u'columns[%d][name]' % i])
95+
# (canada fork only): disable FTS wildcarding
96+
# https://github.com/ckan/ckan/issues/8583
9597
# replace non-alphanumeric characters with FTS wildcard (_)
96-
v = re.sub(r'[^0-9a-zA-Z\-]+', '_', v)
98+
# v = re.sub(r'[^0-9a-zA-Z\-]+', '_', v)
9799
# append ':*' so we can do partial FTS searches
98-
colsearch_dict[k] = v + u':*'
100+
colsearch_dict[k] = f'{v}:*'
99101
i += 1
100102

101103
if colsearch_dict:
102104
search_text = json.dumps(colsearch_dict)
103105
else:
104-
search_text = re.sub(r'[^0-9a-zA-Z\-]+', '_',
105-
search_text) + u':*' if search_text else u''
106+
# (canada fork only): disable FTS wildcarding
107+
# https://github.com/ckan/ckan/issues/8583
108+
# search_text = re.sub(r'[^0-9a-zA-Z\-]+', '_',
109+
# search_text) + u':*' if search_text else u''
110+
search_text = f'{search_text}:*' if search_text else ''
106111

107112
try:
108113
response = datastore_search(

0 commit comments

Comments
 (0)