Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryBuilder: Implementation of contains Filter Operator applied to JSON Fields for SQLite backend #6619

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a9165f9
add tests to `contains` filter operator on PostgreSQL backend
dependabot[bot] Nov 6, 2024
ab88f00
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2024
518cc6b
Merge branch 'main' into test-json-contains
rabbull Nov 19, 2024
ec36aae
temp
rabbull Nov 19, 2024
474dd26
add tests for nested arrays
rabbull Nov 19, 2024
a759d43
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2024
5b7b62b
update
rabbull Nov 19, 2024
e23ec32
custom function
rabbull Nov 19, 2024
e530f03
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2024
6df03e3
cleanup
rabbull Nov 19, 2024
84c50f6
catchup
rabbull Nov 19, 2024
f787404
fix compilation error on py39
rabbull Nov 20, 2024
36c7102
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 20, 2024
dcd3cf9
add benchmark
rabbull Nov 20, 2024
d293d18
ignore benchmark results
rabbull Nov 20, 2024
a34623f
Merge branch 'test-json-contains' into sqlite-json-contains
rabbull Nov 20, 2024
079cc32
remove requires_psql marks for sqlite tests
rabbull Nov 20, 2024
598f821
temp
rabbull Nov 21, 2024
93ad037
add benchmark
rabbull Nov 23, 2024
93966cd
Merge branch 'sqlite-json-contains' of github.com:rabbull/aiida-core …
rabbull Nov 23, 2024
9293c67
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 23, 2024
180bec0
Merge branch 'main' of github.com:rabbull/aiida-core into sqlite-json…
rabbull Nov 26, 2024
edfe2b2
Merge branch 'main' of github.com:rabbull/aiida-core into sqlite-json…
rabbull Nov 26, 2024
2189a81
migrate sqlite filter tests to orm
rabbull Nov 26, 2024
ffa0b11
add comment on impl for psql of_type
rabbull Nov 26, 2024
1ca1d3c
Merge branch 'main' of github.com:rabbull/aiida-core into sqlite-json…
rabbull Dec 5, 2024
c699484
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 5, 2024
9d56802
Merge branch 'main' of github.com:rabbull/aiida-core into sqlite-json…
rabbull Dec 10, 2024
3eca114
Merge branch 'main' of github.com:rabbull/aiida-core into sqlite-json…
rabbull Dec 10, 2024
af544e7
add tests for custom functions
rabbull Dec 10, 2024
fbb7ee3
enable sqlite database backend testing in github actions
rabbull Dec 10, 2024
57beea7
add sqlite to coverage report workflow
rabbull Dec 10, 2024
7e78b22
Merge branch 'main' of github.com:rabbull/aiida-core into sqlite-json…
rabbull Dec 17, 2024
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
Prev Previous commit
Next Next commit
fix compilation error on py39
  • Loading branch information
rabbull committed Nov 20, 2024
commit f7874049d0c03f23599aa14e3d3c6e11e448f773
12 changes: 7 additions & 5 deletions src/aiida/storage/sqlite_zip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def sqlite_case_sensitive_like(dbapi_connection, _):
cursor.close()


def _contains(lhs: dict | list, rhs: dict | list):
def _contains(lhs: Union[dict, list], rhs: Union[dict, list]):
rabbull marked this conversation as resolved.
Show resolved Hide resolved
if isinstance(lhs, dict) and isinstance(rhs, dict):
for key in rhs:
if key not in lhs or not _contains(lhs[key], rhs[key]):
Expand All @@ -63,13 +63,15 @@ def _contains(lhs: dict | list, rhs: dict | list):
return lhs == rhs


def _json_contains(json1_str: AnyStr, json2_str: AnyStr):
def _json_contains(lhs: Union[str, bytes, bytearray, dict, list], rhs: Union[str, bytes, bytearray, dict, list]):
try:
json1 = json.loads(json1_str)
json2 = json.loads(json2_str)
if isinstance(lhs, (str, bytes, bytearray)):
lhs = json.loads(lhs)
if isinstance(rhs, (str, bytes, bytearray)):
rhs = json.loads(rhs)
except json.JSONDecodeError:
return 0
return int(_contains(json1, json2))
return int(_contains(lhs, rhs))


def register_json_contains(dbapi_connection, _):
Expand Down
Loading