Skip to content

Commit 6e53b72

Browse files
Fix regression with backslashes in queries.
1 parent 83dfccd commit 6e53b72

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

datajoint/condition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def prep_value(k, v):
109109
):
110110
return '"%s"' % v
111111
if isinstance(v, str):
112-
return '"%s"' % v.replace("%", "%%")
112+
return '"%s"' % v.replace("%", "%%").replace("\\", "\\\\")
113113
return "%r" % v
114114

115115
negate = False

local-docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ services:
8282
- -c
8383
- |
8484
set -e
85-
pip install --user nose nose-cov coveralls flake8 ptvsd black
85+
pip install --user nose nose-cov coveralls flake8 ptvsd black faker
8686
pip install -e .
8787
pip freeze | grep datajoint
8888
## You may run the below tests once sh'ed into container i.e. docker exec -it datajoint-python_app_1 sh

tests/test_fetch.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,11 @@ def test_dj_u_distinct(self):
380380
fetched_result = result.fetch(as_dict=True, order_by=("contrast", "brightness"))
381381
Stimulus.delete_quick()
382382
assert fetched_result == expected_result
383+
384+
def test_backslash(self):
385+
# https://github.com/datajoint/datajoint-python/issues/999
386+
expected = "She\Hulk"
387+
Parent.insert([(2, expected)])
388+
q = Parent & dict(name=expected)
389+
assert q.fetch1("name") == expected
390+
q.delete()

0 commit comments

Comments
 (0)