Skip to content

Commit a430b42

Browse files
committed
select() should maybe accept no variables too
1 parent 8cfc0b5 commit a430b42

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

terminusdb_client/tests/test_woql_schema_validation.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,53 @@ def test_select_with_subquery(self):
123123
assert "query" in query._cursor
124124
assert result is query
125125

126+
@pytest.mark.skip(reason="""BLOCKED: Bug in woql_query.py line 784 - unreachable validation logic
127+
128+
BUG ANALYSIS:
129+
Line 784: if queries != [] and not queries:
130+
131+
This condition is LOGICALLY IMPOSSIBLE and can never be True:
132+
- 'queries != []' means queries is not an empty list (truthy or non-empty)
133+
- 'not queries' means queries is falsy (empty list, None, False, 0, etc.)
134+
- These two conditions are mutually exclusive
135+
136+
CORRECT BEHAVIOR (from JavaScript client line 314):
137+
if (!varNames || varNames.length <= 0) {
138+
return this.parameterError('Select must be given a list of variable names');
139+
}
140+
141+
Python equivalent should be:
142+
if not queries or len(queries) == 0:
143+
raise ValueError("Select must be given a list of variable names")
144+
145+
IMPACT:
146+
- select() with no arguments: Should raise ValueError, but doesn't (line 786 handles empty list)
147+
- select(None): Should raise ValueError, but doesn't (None is falsy but != [])
148+
- Validation is completely bypassed
149+
150+
FIX REQUIRED:
151+
Replace line 784 with: if not queries:
152+
This will catch None, empty list, and other falsy values before processing.
153+
""")
154+
def test_select_with_no_arguments_should_raise_error(self):
155+
"""Test that select() with no arguments raises ValueError.
156+
157+
According to JavaScript client behavior (line 314-316), select() must be
158+
given at least one variable name. Calling with no arguments should raise
159+
a ValueError with message "Select must be given a list of variable names".
160+
161+
The case to have zero variables selected is a valid case, where outer
162+
variables are used in a subclause and no additional variables from the
163+
inner function should be in the result. Thus both javascript and
164+
Python clients are probably wrong.
165+
"""
166+
query = WOQLQuery()
167+
168+
# Test: No arguments at all should raise ValueError
169+
# Currently FAILS because line 784 validation is unreachable
170+
with pytest.raises(ValueError, match="Select must be given a list of variable names"):
171+
query.select()
172+
126173
def test_select_with_empty_list(self):
127174
"""Test select with empty list."""
128175
query = WOQLQuery()

0 commit comments

Comments
 (0)