Skip to content

Commit b601d8f

Browse files
committed
Support for less than or equal, and greater than or equal
1 parent 82f0319 commit b601d8f

1 file changed

Lines changed: 52 additions & 6 deletions

File tree

terminusdb_client/woqlquery/woql_query.py

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,9 +2143,9 @@ def less(self, left, right):
21432143
21442144
Parameters
21452145
----------
2146-
left : str
2146+
left : str or number
21472147
first variable to compare
2148-
right : str
2148+
right : str or number
21492149
second variable to compare
21502150
21512151
Returns
@@ -2155,6 +2155,8 @@ def less(self, left, right):
21552155
"""
21562156
if left and left == "args":
21572157
return ["left", "right"]
2158+
if left is None or right is None:
2159+
raise ValueError("Less takes two parameters")
21582160
if self._cursor.get("@type"):
21592161
self._wrap_cursor_with_and()
21602162
self._cursor["@type"] = "Less"
@@ -2167,25 +2169,69 @@ def greater(self, left, right):
21672169
21682170
Parameters
21692171
----------
2170-
left : str
2172+
left : str or number
21712173
first variable to compare
2172-
right : str
2174+
right : str or number
21732175
second variable to compare
21742176
21752177
Returns
21762178
-------
21772179
WOQLQuery object
21782180
query object that can be chained and/or execute
21792181
"""
2180-
if left and left == "args":
2181-
return ["left", "right"]
2182+
if left is None or right is None:
2183+
raise ValueError("Greater takes two parameters")
21822184
if self._cursor.get("@type"):
21832185
self._wrap_cursor_with_and()
21842186
self._cursor["@type"] = "Greater"
21852187
self._cursor["left"] = self._clean_object(left)
21862188
self._cursor["right"] = self._clean_object(right)
21872189
return self
21882190

2191+
def gte(self, left, right):
2192+
"""Compares two values using greater-than-or-equal ordering.
2193+
Parameters
2194+
----------
2195+
left : str or number
2196+
the greater or equal value
2197+
right : str or number
2198+
the lesser or equal value
2199+
Returns
2200+
-------
2201+
WOQLQuery object
2202+
query object that can be chained and/or execute
2203+
"""
2204+
if left is None or right is None:
2205+
raise ValueError("Gte takes two parameters")
2206+
if self._cursor.get("@type"):
2207+
self._wrap_cursor_with_and()
2208+
self._cursor["@type"] = "Gte"
2209+
self._cursor["left"] = self._clean_object(left)
2210+
self._cursor["right"] = self._clean_object(right)
2211+
return self
2212+
2213+
def lte(self, left, right):
2214+
"""Compares two values using less-than-or-equal ordering.
2215+
Parameters
2216+
----------
2217+
left : str or number
2218+
the lesser or equal value
2219+
right : str or number
2220+
the greater or equal value
2221+
Returns
2222+
-------
2223+
WOQLQuery object
2224+
query object that can be chained and/or execute
2225+
"""
2226+
if left is None or right is None:
2227+
raise ValueError("Lte takes two parameters")
2228+
if self._cursor.get("@type"):
2229+
self._wrap_cursor_with_and()
2230+
self._cursor["@type"] = "Lte"
2231+
self._cursor["left"] = self._clean_object(left)
2232+
self._cursor["right"] = self._clean_object(right)
2233+
return self
2234+
21892235
def opt(self, query=None):
21902236
"""The Query in the Optional argument is specified as optional
21912237

0 commit comments

Comments
 (0)