Skip to content

Commit c732bae

Browse files
committed
Fix: 'instrument' interpreted as filter 'in strument'
1 parent 3f64344 commit c732bae

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

astroquery/eso/tests/test_eso.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,17 @@ def test_tap_url():
301301
(">1.23", "> 1.23"),
302302
("<'5'", "< '5'"),
303303
(">'1.23'", "> '1.23'"),
304-
("like'%John%'", "like '%John%'"),
305304
306305
# Strings that look like operators but should be treated as strings
307306
("'like %John%'", "= 'like %John%'"),
308307
("'= something'", "= '= something'"),
309308
("'> 5'", "= '> 5'"),
310309
("' > 1.23 '", "= ' > 1.23 '"),
310+
("likewise", "= 'likewise'"),
311+
("INfinity", "= 'INfinity'"),
312+
("like'%John%'", "= 'like'%John%''"), #pathologic case
311313
312-
# Ill-formed queries: not sanitized but expected to be passed through as-is
314+
# Ill-formed queries: Operator, but not sanitized. Expected to be passed through as-is
313315
("like %John%", "like %John%"),
314316
("not like %John%", "not like %John%"),
315317
("= SGR A", "= SGR A"),

astroquery/eso/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ def _adql_sanitize_op_val(op_val):
114114
returns "<operator> <value>" if operator is provided.
115115
Defaults to "= <value>" otherwise.
116116
"""
117-
supported_operators = {"=", ">", "<", "<=", ">=", "!=", "like", "between", "in",
118-
"not like", "not in"}
117+
supported_operators = {"=", ">", "<", "<=", ">=", "!=", "like ", "between ", "in ",
118+
"not like ", "not in "}
119119

120120
if not isinstance(op_val, str):
121121
return f"= {op_val}"
@@ -124,7 +124,7 @@ def _adql_sanitize_op_val(op_val):
124124
for s in supported_operators:
125125
if op_val.lower().startswith(s):
126126
operator, value = s, op_val[len(s):].strip()
127-
return f"{operator} {value}"
127+
return f"{operator.strip()} {value}"
128128

129129
# Default case: no operator. Assign "="
130130
value = op_val if (op_val.startswith("'") and op_val.endswith("'")) else f"'{op_val}'"

0 commit comments

Comments
 (0)