Skip to content

Commit b2ef6d9

Browse files
committed
Added skip_strip_code argument
1 parent 975c5c4 commit b2ef6d9

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ Client().query(
315315
code: str,
316316
scope: Optional[str] = None,
317317
timeout: Optional[int] = None,
318+
skip_strip_code: bool = False,
318319
**kwargs: Any
319320
) -> asyncio.Future
320321
```
@@ -335,6 +336,10 @@ Use this method to run `code` in a scope.
335336
Raise a time-out exception if no response is received within X
336337
seconds. If no time-out is given, the client will wait forever.
337338
Defaults to `None`.
339+
- *skip_strip_code (bool, optional)*:
340+
This can be set to `True` which can be helpful when line numbers
341+
in syntax errors need to match. When `False`, the code will be
342+
stripped from white-space and comments to reduce the code size.
338343
- *\*\*kwargs (any, optional)*:
339344
Can be used to inject variable into the ThingsDB code.
340345

thingsdb/client/client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ def query(
294294
code: str,
295295
scope: Optional[str] = None,
296296
timeout: Optional[int] = None,
297+
skip_strip_code: bool = False,
297298
**kwargs: Any
298299
) -> asyncio.Future:
299300
"""Query ThingsDB.
@@ -311,6 +312,10 @@ def query(
311312
Raise a time-out exception if no response is received within X
312313
seconds. If no time-out is given, the client will wait forever.
313314
Defaults to `None`.
315+
skip_strip_code (bool, optional):
316+
This can be set to True which can be helpful when line numbers
317+
in syntax errors need to match. When False, the code will be
318+
stripped from white-space and comments to reduce the code size.
314319
**kwargs (any, optional):
315320
Can be used to inject variable into the ThingsDB code.
316321
@@ -337,7 +342,9 @@ def query(
337342
if scope is None:
338343
scope = self._scope
339344

340-
code = strip_code(code)
345+
if skip_strip_code is False:
346+
code = strip_code(code)
347+
341348
data = [scope, code]
342349
if kwargs:
343350
data.append(kwargs)

thingsdb/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.1.0'
1+
__version__ = '1.1.1'

0 commit comments

Comments
 (0)