Skip to content

Commit

Permalink
catchup
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbull committed Nov 19, 2024
2 parents 6df03e3 + e530f03 commit 84c50f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/aiida/storage/sqlite_zip/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from functools import singledispatch
from typing import Any, List, Optional, Tuple, Union

from sqlalchemy import JSON, case, func, select, true, not_
from sqlalchemy import JSON, case, func, select
from sqlalchemy.orm.util import AliasedClass
from sqlalchemy.sql import ColumnElement

Expand Down
5 changes: 4 additions & 1 deletion src/aiida/storage/sqlite_zip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import json
import zipfile
from pathlib import Path
from typing import Any, Dict, Optional, Union, AnyStr
from typing import Any, AnyStr, Dict, Optional, Union

from sqlalchemy import event
from sqlalchemy.future.engine import Engine, create_engine
Expand Down Expand Up @@ -47,6 +47,7 @@ def sqlite_case_sensitive_like(dbapi_connection, _):
cursor.execute('PRAGMA case_sensitive_like=ON;')
cursor.close()


def _contains(lhs: dict | list, rhs: dict | list):
if isinstance(lhs, dict) and isinstance(rhs, dict):
for key in rhs:
Expand All @@ -61,6 +62,7 @@ def _contains(lhs: dict | list, rhs: dict | list):
else:
return lhs == rhs


def _json_contains(json1_str: AnyStr, json2_str: AnyStr):
try:
json1 = json.loads(json1_str)
Expand All @@ -69,6 +71,7 @@ def _json_contains(json1_str: AnyStr, json2_str: AnyStr):
return 0
return int(_contains(json1, json2))


def register_json_contains(dbapi_connection, _):
dbapi_connection.create_function('json_contains', 2, _json_contains)

Expand Down

0 comments on commit 84c50f6

Please sign in to comment.