Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit efd90e1

Browse filesBrowse files
committed
fix: change function substring into a standalone function
1 parent 1385798 commit efd90e1
Copy full SHA for efd90e1

File tree

Expand file treeCollapse file tree

2 files changed

+13
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-13
lines changed
Open diff view settings
Collapse file

‎jsonquerylang/functions.py‎

Copy file name to clipboardExpand all lines: jsonquerylang/functions.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def key_by(data):
148148
text.split(separator) if separator is not "" else split_chars(text)
149149
)
150150
)
151-
fn_substring = lambda start, end=None: lambda data: data[max(start, 0) : end]
151+
fn_substring = build_function(lambda text, start, end=None: text[max(start, 0) : end])
152152
fn_uniq = lambda: lambda data: list(dict.fromkeys(data))
153153
fn_uniq_by = lambda path: lambda data: list(fn_key_by(path)(data).values())
154154
fn_limit = lambda count: lambda data: data[0:count] if count >= 0 else []
Collapse file

‎tests/test-suite/compile.test.json‎

Copy file name to clipboardExpand all lines: tests/test-suite/compile.test.json
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"source": "https://github.com/jsonquerylang/jsonquery/tree/main/test-suite/compile.test.json",
3-
"updated": "2024-12-02T11:00:00Z",
3+
"updated": "2024-12-03T09:00:00Z",
44
"tests": [
55
{
66
"category": "value",
@@ -543,42 +543,42 @@
543543
"category": "substring",
544544
"description": "should get a substring of a string with a start index",
545545
"input": "123456",
546-
"query": ["substring", 3],
546+
"query": ["substring", ["get"], 3],
547547
"output": "456"
548548
},
549549
{
550550
"category": "substring",
551551
"description": "should get a substring of a string with a start and end index",
552-
"input": "123456",
553-
"query": ["substring", 2, 4],
552+
"input": { "value": "123456" },
553+
"query": ["substring", ["get", "value"], 2, 4],
554554
"output": "34"
555555
},
556556
{
557557
"category": "substring",
558558
"description": "should get a substring of a string with a start exceeding the string length",
559-
"input": "123456",
560-
"query": ["substring", 10],
559+
"input": null,
560+
"query": ["substring", "123456", 10],
561561
"output": ""
562562
},
563563
{
564564
"category": "substring",
565565
"description": "should get a substring of a string with an end exceeding the string length",
566-
"input": "123456",
567-
"query": ["substring", 0, 10],
566+
"input": null,
567+
"query": ["substring", "123456", 0, 10],
568568
"output": "123456"
569569
},
570570
{
571571
"category": "substring",
572572
"description": "should get a substring of a string with an end index smaller than the start index",
573-
"input": "123456",
574-
"query": ["substring", 3, 0],
573+
"input": null,
574+
"query": ["substring", "123456", 3, 0],
575575
"output": ""
576576
},
577577
{
578578
"category": "substring",
579579
"description": "should get a substring of a string with a negative start index",
580-
"input": "123456",
581-
"query": ["substring", -2],
580+
"input": null,
581+
"query": ["substring", "123456", -2],
582582
"output": "123456"
583583
},
584584

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.