Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def test_prop_or_prop() -> None:
{},
)
assert str(query) == (
'((json_extract(properties, "$.int") == 2) OR '
'(json_extract(properties, "$.int") == 3))'
"""((json_extract(properties, '$."int"') == 2) OR """
"""(json_extract(properties, '$."int"') == 3))"""
)


Expand Down
6 changes: 3 additions & 3 deletions tiatoolbox/annotation/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ def __init__(self: SQLJSONDictionary, acc: str | None = None) -> None:

def __str__(self: SQLJSONDictionary) -> str:
"""Return a human-readable, or informal, string representation of an object."""
return f"json_extract(properties, {json.dumps(f'$.{self.acc}')})"
return f"json_extract(properties, '$.{self.acc}')"

def __getitem__(self: SQLJSONDictionary, key: str) -> SQLJSONDictionary:
"""Get an item from the dataset."""
key_str = f"[{key}]" if isinstance(key, (int,)) else str(key)
key_str = f"[{key}]" if isinstance(key, (int,)) else f'"{key}"'

joiner = "." if self.acc and not isinstance(key, int) else ""
return SQLJSONDictionary(acc=self.acc + joiner + f"{key_str}")
return SQLJSONDictionary(acc=self.acc + joiner + key_str)

def get(
self: SQLJSONDictionary,
Expand Down